diff --git a/aai_cli/config.py b/aai_cli/config.py index 782bba60..322e06ca 100644 --- a/aai_cli/config.py +++ b/aai_cli/config.py @@ -70,8 +70,6 @@ def validate_profile(name: str) -> None: tripping over it at keyring-write time. """ if not _PROFILE_RE.match(name): - from aai_cli.errors import CLIError - raise CLIError( f"Invalid profile name {name!r}.", error_type="invalid_profile", @@ -132,8 +130,6 @@ def _load() -> Config: try: data = tomllib.load(fh) except tomllib.TOMLDecodeError as exc: - from aai_cli.errors import CLIError - raise CLIError( f"Config file at {path} is not valid TOML ({exc}). Fix or delete it.", error_type="invalid_config", @@ -142,8 +138,6 @@ def _load() -> Config: try: cfg = Config.model_validate(data) except ValidationError as exc: - from aai_cli.errors import CLIError - raise CLIError( f"Config file at {path} has an unexpected shape " f"({_validation_summary(exc)}). Fix or delete it.", @@ -459,8 +453,6 @@ def _resolve_api_key(*, profile: str | None, api_key_flag: str | None) -> str: if api_key_flag is not None: flag_key = api_key_flag.strip() if not flag_key: - from aai_cli.errors import CLIError - raise CLIError( "Empty --api-key provided.", error_type="invalid_key", diff --git a/aai_cli/context.py b/aai_cli/context.py index c2a3952b..0d848855 100644 --- a/aai_cli/context.py +++ b/aai_cli/context.py @@ -56,8 +56,6 @@ def resolve_session(self) -> tuple[int, str]: key. Raises NotAuthenticated when the active profile has no stored session (e.g. it was set up with `assembly login --api-key`, or the session expired). """ - from aai_cli.errors import NotAuthenticated - profile = self.resolve_profile() session = config.get_session(profile) account_id = config.get_account_id(profile) diff --git a/aai_cli/output.py b/aai_cli/output.py index e974c72c..2354906e 100644 --- a/aai_cli/output.py +++ b/aai_cli/output.py @@ -35,9 +35,7 @@ def is_agentic() -> bool: env var is set. Used to suppress *interactivity* (the spinner) — never to change the output *shape*; `resolve_json` keeps text the default regardless (see its docstring). """ - if not _stdout_is_tty(): - return True - return any(os.environ.get(var) for var in _AGENT_ENV_VARS) + return not _stdout_is_tty() or any(os.environ.get(var) for var in _AGENT_ENV_VARS) def set_color_mode(mode: choices.ColorMode) -> None: