chore: ruff auto-fix PLR6201 resweep — tuple → set in membership tests (#27355)

Six days after #23937 (608 fixes) the codebase had accumulated 241 new
PLR6201 violations. Same mechanical `x in (...)` → `x in {...}` fix,
same zero-risk profile: set lookup is O(1) vs O(n) for tuple and the
two are semantically equivalent for hashable scalar membership tests.

All 241 instances fixed via `ruff check --select PLR6201 --fix
--unsafe-fixes`, zero remaining. Every changed value is a hashable
scalar (str/int/None/enum/signal); no risk of unhashable runtime
errors. No behavior change.

Test plan:
- 119 files changed, +244/-244 (net zero) — exactly one-line edits
- `ruff check` clean afterward
- Compile checks pass on the largest touched files (cli.py, run_agent.py,
  gateway/run.py, gateway/platforms/discord.py, model_tools.py)
- Subset broad test run on tests/gateway/ tests/hermes_cli/ tests/agent/
  tests/tools/: 18187 passed, 59 pre-existing failures (verified against
  origin/main with the same shape — identical failure count, identical
  category — all xdist test-order flakes unrelated to this change)

Follows the same template as PR #23937 ([tracker: #23972](https://github.com/NousResearch/hermes-agent/issues/23972)).
This commit is contained in:
kshitij 2026-05-17 02:29:41 -07:00 committed by GitHub
parent ad00777f04
commit 5fba236644
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
119 changed files with 244 additions and 244 deletions

View file

@ -233,7 +233,7 @@ _profile_override: str | None = None
def _host_key() -> str:
"""Return the active Honcho host key, derived from the current Hermes profile."""
if _profile_override:
if _profile_override in ("default", "custom"):
if _profile_override in {"default", "custom"}:
return HOST
return f"{HOST}.{_profile_override}"
return resolve_active_host()
@ -295,13 +295,13 @@ def _resolve_api_key(cfg: dict) -> str:
parsed = urlparse(base_url)
except (TypeError, ValueError):
parsed = None
if parsed and parsed.scheme in ("http", "https") and parsed.netloc:
if parsed and parsed.scheme in {"http", "https"} and parsed.netloc:
return "local"
# Schemeless but looks like a host (contains '.' or ':' and isn't
# a boolean literal): let it through so legacy configs don't
# regress into "no API key configured" when they previously worked.
lowered = base_url.lower()
if lowered not in ("true", "false", "none", "null") and any(
if lowered not in {"true", "false", "none", "null"} and any(
c in base_url for c in ".:"
) and not base_url.isdigit():
return "local"
@ -334,7 +334,7 @@ def _ensure_sdk_installed() -> bool:
print(" honcho-ai is not installed.")
answer = _prompt("Install it now? (honcho-ai>=2.0.1)", default="y")
if answer.lower() not in ("y", "yes"):
if answer.lower() not in {"y", "yes"}:
print(" Skipping install. Run: pip install 'honcho-ai>=2.0.1'\n")
return False
@ -382,7 +382,7 @@ def cmd_setup(args) -> None:
for h in ("localhost", "127.0.0.1", "::1")
) else "cloud"
deploy = _prompt("Cloud or local?", default=current_deploy)
is_local = deploy.lower() in ("local", "l")
is_local = deploy.lower() in {"local", "l"}
# Clean up legacy snake_case key
cfg.pop("base_url", None)
@ -441,7 +441,7 @@ def cmd_setup(args) -> None:
print(" directional -- all observations on, each AI peer builds its own view (default)")
print(" unified -- shared pool, user observes self, AI observes others only")
new_obs = _prompt("Observation mode", default=current_obs)
if new_obs in ("unified", "directional"):
if new_obs in {"unified", "directional"}:
hermes_host["observationMode"] = new_obs
else:
hermes_host["observationMode"] = "directional"
@ -457,17 +457,17 @@ def cmd_setup(args) -> None:
try:
hermes_host["writeFrequency"] = int(new_wf)
except (ValueError, TypeError):
hermes_host["writeFrequency"] = new_wf if new_wf in ("async", "turn", "session") else "async"
hermes_host["writeFrequency"] = new_wf if new_wf in {"async", "turn", "session"} else "async"
# --- 6. Recall mode ---
_raw_recall = hermes_host.get("recallMode") or cfg.get("recallMode", "hybrid")
current_recall = "hybrid" if _raw_recall not in ("hybrid", "context", "tools") else _raw_recall
current_recall = "hybrid" if _raw_recall not in {"hybrid", "context", "tools"} else _raw_recall
print("\n Recall mode:")
print(" hybrid -- auto-injected context + Honcho tools available (default)")
print(" context -- auto-injected context only, Honcho tools hidden")
print(" tools -- Honcho tools only, no auto-injected context")
new_recall = _prompt("Recall mode", default=current_recall)
if new_recall in ("hybrid", "context", "tools"):
if new_recall in {"hybrid", "context", "tools"}:
hermes_host["recallMode"] = new_recall
# --- 7. Context token budget ---
@ -477,7 +477,7 @@ def cmd_setup(args) -> None:
print(" uncapped -- no limit (default)")
print(" N -- token limit per turn (e.g. 1200)")
new_ctx_tokens = _prompt("Context tokens", default=current_display)
if new_ctx_tokens.strip().lower() in ("none", "uncapped", "no limit"):
if new_ctx_tokens.strip().lower() in {"none", "uncapped", "no limit"}:
hermes_host.pop("contextTokens", None)
elif new_ctx_tokens.strip() == "":
pass # keep current
@ -517,7 +517,7 @@ def cmd_setup(args) -> None:
print(" high -- complex behavioral patterns")
print(" max -- thorough audit-level analysis")
new_reasoning = _prompt("Reasoning level", default=current_reasoning)
if new_reasoning in ("minimal", "low", "medium", "high", "max"):
if new_reasoning in {"minimal", "low", "medium", "high", "max"}:
hermes_host["dialecticReasoningLevel"] = new_reasoning
else:
hermes_host["dialecticReasoningLevel"] = "low"
@ -530,7 +530,7 @@ def cmd_setup(args) -> None:
print(" per-repo -- one session per git repository")
print(" global -- single session across all directories")
new_strat = _prompt("Session strategy", default=current_strat)
if new_strat in ("per-session", "per-repo", "per-directory", "global"):
if new_strat in {"per-session", "per-repo", "per-directory", "global"}:
hermes_host["sessionStrategy"] = new_strat
hermes_host["enabled"] = True
@ -1130,7 +1130,7 @@ def cmd_migrate(args) -> None:
print(" Paste the key when prompted.")
print()
answer = _prompt(" Run 'hermes honcho setup' now?", default="y")
if answer.lower() in ("y", "yes"):
if answer.lower() in {"y", "yes"}:
cmd_setup(args)
cfg = _read_config()
has_key = bool(cfg.get("apiKey", ""))
@ -1176,7 +1176,7 @@ def cmd_migrate(args) -> None:
print(" hermes honcho migrate — this step handles it interactively")
if has_key:
answer = _prompt(" Upload user memory files to Honcho now?", default="y")
if answer.lower() in ("y", "yes"):
if answer.lower() in {"y", "yes"}:
try:
from plugins.memory.honcho.client import (
HonchoClientConfig,
@ -1226,7 +1226,7 @@ def cmd_migrate(args) -> None:
print()
if has_key:
answer = _prompt(" Seed AI identity from all detected files now?", default="y")
if answer.lower() in ("y", "yes"):
if answer.lower() in {"y", "yes"}:
try:
from plugins.memory.honcho.client import (
HonchoClientConfig,