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

Replace  with  for all literal-tuple
membership tests. Set lookup is O(1) vs O(n) for tuple — consistent
micro-optimization across the codebase.

608 instances fixed via `ruff --fix --unsafe-fixes`, 0 remaining.
133 files, +626/-626 (net zero).
This commit is contained in:
kshitij 2026-05-11 11:13:25 -07:00 committed by GitHub
parent 8c11710314
commit 2ec8d2b42f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
133 changed files with 626 additions and 626 deletions

36
cli.py
View file

@ -1741,7 +1741,7 @@ def _detect_file_drop(user_input: str) -> "dict | None":
or stripped.startswith("./")
or stripped.startswith("../")
or stripped.startswith("file://")
or (len(stripped) >= 3 and stripped[1] == ":" and stripped[2] in ("\\", "/") and stripped[0].isalpha())
or (len(stripped) >= 3 and stripped[1] == ":" and stripped[2] in {"\\", "/"} and stripped[0].isalpha())
or stripped.startswith('"/')
or stripped.startswith('"~')
or stripped.startswith("'/")
@ -1750,7 +1750,7 @@ def _detect_file_drop(user_input: str) -> "dict | None":
or stripped.startswith('"../')
or stripped.startswith("'./")
or stripped.startswith("'../")
or (len(stripped) >= 4 and stripped[0] in ("'", '"') and stripped[2] == ":" and stripped[3] in ("\\", "/") and stripped[1].isalpha())
or (len(stripped) >= 4 and stripped[0] in {"'", '"'} and stripped[2] == ":" and stripped[3] in {"\\", "/"} and stripped[1].isalpha())
)
if not starts_like_path:
return None
@ -2487,7 +2487,7 @@ class HermesCLI:
_or_cfg = CLI_CONFIG.get("openrouter", {}) or {}
_raw_score = _or_cfg.get("min_coding_score")
self._openrouter_min_coding_score: Optional[float] = None
if _raw_score not in (None, ""):
if _raw_score not in {None, ""}:
try:
_f = float(_raw_score)
if 0.0 <= _f <= 1.0:
@ -4663,7 +4663,7 @@ class HermesCLI:
parts = command.split()
subcmd = parts[1].lower() if len(parts) > 1 else "list"
if subcmd in ("list", "ls"):
if subcmd in {"list", "ls"}:
snaps = list_quick_snapshots()
if not snaps:
print(" No state snapshots yet.")
@ -4691,7 +4691,7 @@ class HermesCLI:
else:
print(" No state files found to snapshot.")
elif subcmd in ("restore", "rewind"):
elif subcmd in {"restore", "rewind"}:
if len(parts) < 3:
print(" Usage: /snapshot restore <snapshot-id>")
# Show hint with most recent snapshot
@ -5230,7 +5230,7 @@ class HermesCLI:
parts = cmd.split()
subcommand = parts[1] if len(parts) > 1 else ""
if subcommand not in ("list", "disable", "enable"):
if subcommand not in {"list", "disable", "enable"}:
self.show_tools()
return
@ -6814,7 +6814,7 @@ class HermesCLI:
# Set personality
personality_name = parts[1].strip().lower()
if personality_name in ("none", "default", "neutral"):
if personality_name in {"none", "default", "neutral"}:
self.system_prompt = ""
self.agent = None # Force re-init
if save_config_value("agent.system_prompt", ""):
@ -7222,7 +7222,7 @@ class HermesCLI:
_cmd_def = _resolve_cmd(_base_word)
canonical = _cmd_def.name if _cmd_def else _base_word
if canonical in ("quit", "exit"):
if canonical in {"quit", "exit"}:
return False
elif canonical == "help":
self.show_help()
@ -8096,7 +8096,7 @@ class HermesCLI:
)
return
if lower in ("clear", "stop", "done"):
if lower in {"clear", "stop", "done"}:
had = mgr.has_goal()
mgr.clear()
if had:
@ -8186,7 +8186,7 @@ class HermesCLI:
parts = [
p.get("text", "")
for p in content
if isinstance(p, dict) and p.get("type") in ("text", "output_text")
if isinstance(p, dict) and p.get("type") in {"text", "output_text"}
]
last_response = "\n".join(t for t in parts if t)
else:
@ -8281,7 +8281,7 @@ class HermesCLI:
current = bool(footer_cfg.get("enabled", False))
fields = footer_cfg.get("fields") or ["model", "context_pct", "cwd"]
if arg in ("status", "?"):
if arg in {"status", "?"}:
state = "ON" if current else "OFF"
_cprint(
f" {_Colors.BOLD}Runtime footer:{_Colors.RESET} {state}\n"
@ -8289,9 +8289,9 @@ class HermesCLI:
)
return
if arg in ("on", "enable", "true", "1"):
if arg in {"on", "enable", "true", "1"}:
new_state = True
elif arg in ("off", "disable", "false", "0"):
elif arg in {"off", "disable", "false", "0"}:
new_state = False
elif arg == "":
new_state = not current
@ -8384,7 +8384,7 @@ class HermesCLI:
arg = parts[1].strip().lower()
# Display toggle
if arg in ("show", "on"):
if arg in {"show", "on"}:
self.show_reasoning = True
if self.agent:
self.agent.reasoning_callback = self._current_reasoning_callback()
@ -8392,7 +8392,7 @@ class HermesCLI:
_cprint(f" {_ACCENT}✓ Reasoning display: ON (saved){_RST}")
_cprint(f" {_DIM} Model thinking will be shown during and after each response.{_RST}")
return
if arg in ("hide", "off"):
if arg in {"hide", "off"}:
self.show_reasoning = False
if self.agent:
self.agent.reasoning_callback = self._current_reasoning_callback()
@ -9154,7 +9154,7 @@ class HermesCLI:
if event_type == "tool.completed":
self._tool_start_time = 0.0
# Print stacked scrollback line for "all" / "new" modes
if function_name and self.tool_progress_mode in ("all", "new"):
if function_name and self.tool_progress_mode in {"all", "new"}:
duration = kwargs.get("duration", 0.0)
is_error = kwargs.get("is_error", False)
# Pop stored args from tool.started for this function
@ -10806,7 +10806,7 @@ class HermesCLI:
try:
from hermes_cli.profiles import get_active_profile_name
profile = get_active_profile_name()
if profile not in ("default", "custom"):
if profile not in {"default", "custom"}:
symbol = f"{profile} {symbol}"
except Exception:
pass
@ -11010,7 +11010,7 @@ class HermesCLI:
# see that they're running without the safety net.
try:
_redact_raw = os.getenv("HERMES_REDACT_SECRETS", "true")
if _redact_raw.lower() not in ("1", "true", "yes", "on"):
if _redact_raw.lower() not in {"1", "true", "yes", "on"}:
self._console_print(
"[bold red]⚠ Secret redaction is DISABLED[/] "
f"(HERMES_REDACT_SECRETS={_redact_raw}). "