mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-20 05:01:30 +00:00
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:
parent
8c11710314
commit
2ec8d2b42f
133 changed files with 626 additions and 626 deletions
|
|
@ -690,7 +690,7 @@ def _extract_docs_links(replies: List[Dict[str, Any]]) -> List[Dict[str, str]]:
|
|||
except (json.JSONDecodeError, TypeError):
|
||||
continue
|
||||
for elem in content.get("elements", []):
|
||||
if elem.get("type") not in ("docs_link", "link"):
|
||||
if elem.get("type") not in {"docs_link", "link"}:
|
||||
continue
|
||||
link_data = elem.get("docs_link") or elem.get("link") or {}
|
||||
url = link_data.get("url", "")
|
||||
|
|
@ -1031,7 +1031,7 @@ def _save_session_history(key: str, messages: List[Dict[str, Any]]) -> None:
|
|||
# Only keep user/assistant messages (strip system messages and tool internals)
|
||||
cleaned = [
|
||||
m for m in messages
|
||||
if m.get("role") in ("user", "assistant") and m.get("content")
|
||||
if m.get("role") in {"user", "assistant"} and m.get("content")
|
||||
]
|
||||
# Keep last N
|
||||
if len(cleaned) > _SESSION_MAX_MESSAGES:
|
||||
|
|
@ -1170,7 +1170,7 @@ async def handle_drive_comment_event(
|
|||
rule = resolve_rule(comments_cfg, file_type, file_token)
|
||||
|
||||
# If no exact match and config has wiki keys, try reverse-lookup
|
||||
if rule.match_source in ("wildcard", "top") and has_wiki_keys(comments_cfg):
|
||||
if rule.match_source in {"wildcard", "top"} and has_wiki_keys(comments_cfg):
|
||||
wiki_token = await _reverse_lookup_wiki_token(client, file_type, file_token)
|
||||
if wiki_token:
|
||||
rule = resolve_rule(comments_cfg, file_type, file_token, wiki_token=wiki_token)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue