diff --git a/hermes_cli/nous_account.py b/hermes_cli/nous_account.py index 1131cb17d1..c3a0b92974 100644 --- a/hermes_cli/nous_account.py +++ b/hermes_cli/nous_account.py @@ -523,9 +523,7 @@ def _tool_access_from_value(value: Any) -> Optional[NousToolAccessInfo]: def _coerced_dataclass(cls, value: Any): """Build ``cls`` from a payload dict (field names = payload keys), coercing by declared type.""" - if not isinstance(value, dict): - return None - return cls(**{f.name: _COERCERS[f.type](value.get(f.name)) for f in fields(cls)}) + return cls(**{f.name: _COERCERS[f.type](value.get(f.name)) for f in fields(cls)}) if isinstance(value, dict) else None def _subscription_from_payload(value: Any) -> Optional[NousPortalSubscriptionInfo]: diff --git a/hermes_cli/nous_billing.py b/hermes_cli/nous_billing.py index 354b1f1700..3e383bb3a5 100644 --- a/hermes_cli/nous_billing.py +++ b/hermes_cli/nous_billing.py @@ -18,8 +18,7 @@ from typing import Any, Optional DEFAULT_PORTAL_BASE_URL = "https://portal.nousresearch.com" -# Tight so a hung portal doesn't freeze the TUI (charge/poll calls are quick). -DEFAULT_TIMEOUT = 15.0 +DEFAULT_TIMEOUT = 15.0 # tight so a hung portal doesn't freeze the TUI (charge/poll calls are quick) # --- Typed errors --- @@ -101,8 +100,7 @@ class BillingUpgradeCapExceeded(BillingTransient): def resolve_portal_base_url(state: Optional[dict[str, Any]] = None) -> str: """Resolve the portal base URL with login-time precedence: env, stored state, default.""" env = os.getenv("HERMES_PORTAL_BASE_URL") or os.getenv("NOUS_PORTAL_BASE_URL") - stored = state.get("portal_base_url") if state else None - for candidate in (env, stored): + for candidate in (env, state.get("portal_base_url") if state else None): if isinstance(candidate, str) and candidate.strip(): return candidate.strip().rstrip("/") return DEFAULT_PORTAL_BASE_URL diff --git a/hermes_cli/pairing.py b/hermes_cli/pairing.py index 5eef104cab..47b3298220 100644 --- a/hermes_cli/pairing.py +++ b/hermes_cli/pairing.py @@ -63,8 +63,7 @@ def _cmd_approve(store, platform: str, code: str): else: result = store.approve_code(platform, code.upper()) if result: - uid = result["user_id"] - name = result.get("user_name") or "" + uid, name = result["user_id"], result.get("user_name") or "" display = f"{name} ({uid})" if name else uid print(f"\n Approved! User {display} on {platform} can now use the bot~") print(" They'll be recognized automatically on their next message.\n") diff --git a/hermes_cli/process_identity.py b/hermes_cli/process_identity.py index a8bb8d6336..c4bdafb426 100644 --- a/hermes_cli/process_identity.py +++ b/hermes_cli/process_identity.py @@ -89,9 +89,7 @@ def spawn_env(purpose: str, *, project_root: Optional[Path] = None) -> dict[str, def parse_spawn_tag(raw: object) -> Optional[SpawnTag]: """Parse a ``HERMES_SPAWN`` value; ``None`` for anything malformed.""" - if not isinstance(raw, str): - return None - parts = raw.split(":") + parts = raw.split(":") if isinstance(raw, str) else [] if len(parts) != 5 or parts[0] != _TAG_VERSION: return None _, install, purpose, pid_s, create_s = parts