Skip to content

The agent that grows with you

refactor(hermes_cli): setup cluster — contextlib.suppress for swallow-only try blocks

Tekniumc798443ec7de
diff --git a/hermes_cli/setup_platforms.py b/hermes_cli/setup_platforms.py
index fb647cff796..30b5d5e391a 100644
--- a/hermes_cli/setup_platforms.py
+++ b/hermes_cli/setup_platforms.py
@@ -2,6 +2,7 @@
gateway`` flow. setup.py re-exports the public names, and tests monkeypatch prompt/print/env
helpers on hermes_cli.setup, so those are imported lazily per function."""
+import contextlib
import logging
import re
from pathlib import Path
@@ -29,10 +30,8 @@ def _setup_telegram_auto_result():
except ImportError:
return None
profile_name: str | None = None
- try:
+ with contextlib.suppress(Exception):
profile_name = _profile_name_from_hermes_home(Path(get_hermes_home()))
- except Exception:
- pass
return auto_setup_telegram_bot_result(profile_name=profile_name)
@@ -260,7 +259,7 @@ _HOME_CHANNEL_CHECKS = (
def _is_progress(status: str) -> bool:
"""A platform counts as configured unless its status says otherwise."""
s = status.lower()
- return not (s == "not configured" or s.startswith("partially") or s.startswith("plugin disabled"))
+ return not (s == "not configured" or s.startswith(("partially", "plugin disabled")))
def _warn_missing_home_channels() -> None:
diff --git a/hermes_cli/setup_quick.py b/hermes_cli/setup_quick.py
index 664e5786c4c..c3d68465cd8 100644
--- a/hermes_cli/setup_quick.py
+++ b/hermes_cli/setup_quick.py
@@ -2,6 +2,7 @@
Blank Slate setup and the `--quick` missing-items pass. Names from setup.py are imported lazily
per function so test patches on ``hermes_cli.setup`` take effect."""
+import contextlib
import logging
import os
import sys
@@ -73,10 +74,8 @@ def _run_portal_one_shot(config: dict) -> None:
return
# Re-sync from disk so a caller's later save_config(config) can't clobber the login save.
- try:
+ with contextlib.suppress(Exception):
_reload_config_into(config, dict_only=True)
- except Exception:
- pass
print()
print_success("Portal setup complete.")
_info(" Run `hermes portal info` to inspect routing.", " Run `hermes` to start chatting.")