mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-21 05:11:26 +00:00
chore: ruff auto-fix C401, C416, C408, PLR1722 (#23940)
C401: set(x for x in y) -> {x for x in y} (set comprehension)
C416: [(k,v) for k,v in d] -> list(d.items()) (unnecessary listcomp)
C408: tuple()/dict() -> ()/{} (unnecessary collection call)
PLR1722: exit() -> sys.exit() (adds import sys where needed)
21 instances fixed, 0 remaining. 19 files, +40/-36.
This commit is contained in:
parent
7b76366552
commit
ce0f529cde
19 changed files with 40 additions and 36 deletions
|
|
@ -291,7 +291,7 @@ class MemoryStore:
|
|||
|
||||
if len(matches) > 1:
|
||||
# If all matches are identical (exact duplicates), operate on the first one
|
||||
unique_texts = set(e for _, e in matches)
|
||||
unique_texts = {e for _, e in matches}
|
||||
if len(unique_texts) > 1:
|
||||
previews = [e[:80] + ("..." if len(e) > 80 else "") for _, e in matches]
|
||||
return {
|
||||
|
|
@ -341,7 +341,7 @@ class MemoryStore:
|
|||
|
||||
if len(matches) > 1:
|
||||
# If all matches are identical (exact duplicates), remove the first one
|
||||
unique_texts = set(e for _, e in matches)
|
||||
unique_texts = {e for _, e in matches}
|
||||
if len(unique_texts) > 1:
|
||||
previews = [e[:80] + ("..." if len(e) > 80 else "") for _, e in matches]
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ from typing import Dict, Any, List, Optional
|
|||
from tools.openrouter_client import get_async_client as _get_openrouter_client, check_api_key as check_openrouter_api_key
|
||||
from agent.auxiliary_client import extract_content_or_reasoning
|
||||
from tools.debug_helpers import DebugSession
|
||||
import sys
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -451,7 +452,7 @@ if __name__ == "__main__":
|
|||
print("❌ OPENROUTER_API_KEY environment variable not set")
|
||||
print("Please set your API key: export OPENROUTER_API_KEY='your-key-here'")
|
||||
print("Get API key at: https://openrouter.ai/")
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
else:
|
||||
print("✅ OpenRouter API key found")
|
||||
|
||||
|
|
|
|||
|
|
@ -928,5 +928,5 @@ def _build_summary(name: str, source: str, trust: str, verdict: str, findings: L
|
|||
if not findings:
|
||||
return f"{name}: clean scan, no threats detected"
|
||||
|
||||
categories = set(f.category for f in findings)
|
||||
categories = {f.category for f in findings}
|
||||
return f"{name}: {verdict} — {len(findings)} finding(s) in {', '.join(sorted(categories))}"
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ def reset_bundled_skill(name: str, restore: bool = False) -> dict:
|
|||
manifest = _read_manifest()
|
||||
bundled_dir = _get_bundled_dir()
|
||||
bundled_skills = _discover_bundled_skills(bundled_dir)
|
||||
bundled_by_name = {skill_name: skill_dir for skill_name, skill_dir in bundled_skills}
|
||||
bundled_by_name = dict(bundled_skills)
|
||||
|
||||
in_manifest = name in manifest
|
||||
is_bundled = name in bundled_by_name
|
||||
|
|
|
|||
|
|
@ -721,7 +721,7 @@ def skills_list(category: str = None, task_id: str = None) -> str:
|
|||
|
||||
# Extract unique categories
|
||||
categories = sorted(
|
||||
set(s.get("category") for s in all_skills if s.get("category"))
|
||||
{s.get("category") for s in all_skills if s.get("category")}
|
||||
)
|
||||
|
||||
return json.dumps(
|
||||
|
|
|
|||
|
|
@ -888,6 +888,7 @@ from tools.environments.docker import DockerEnvironment as _DockerEnvironment
|
|||
from tools.environments.modal import ModalEnvironment as _ModalEnvironment
|
||||
from tools.environments.managed_modal import ManagedModalEnvironment as _ManagedModalEnvironment
|
||||
from tools.managed_tool_gateway import is_managed_tool_gateway_ready
|
||||
import sys
|
||||
|
||||
|
||||
# Tool description for LLM
|
||||
|
|
@ -2243,7 +2244,7 @@ if __name__ == "__main__":
|
|||
|
||||
if not check_terminal_requirements():
|
||||
print("\n❌ Requirements not met. Please check the messages above.")
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
print("\n✅ All requirements met!")
|
||||
print("\nAvailable Tool:")
|
||||
|
|
|
|||
|
|
@ -848,13 +848,13 @@ def _generate_openai_tts(text: str, output_path: str, tts_config: Dict[str, Any]
|
|||
OpenAIClient = _import_openai_client()
|
||||
client = OpenAIClient(api_key=api_key, base_url=base_url)
|
||||
try:
|
||||
create_kwargs = dict(
|
||||
model=model,
|
||||
voice=voice,
|
||||
input=text,
|
||||
response_format=response_format,
|
||||
extra_headers={"x-idempotency-key": str(uuid.uuid4())},
|
||||
)
|
||||
create_kwargs = {
|
||||
"model": model,
|
||||
"voice": voice,
|
||||
"input": text,
|
||||
"response_format": response_format,
|
||||
"extra_headers": {"x-idempotency-key": str(uuid.uuid4())},
|
||||
}
|
||||
if speed != 1.0:
|
||||
create_kwargs["speed"] = max(0.25, min(4.0, speed))
|
||||
response = client.audio.speech.create(**create_kwargs)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ from agent.auxiliary_client import async_call_llm, extract_content_or_reasoning
|
|||
from hermes_constants import get_hermes_dir
|
||||
from tools.debug_helpers import DebugSession
|
||||
from tools.website_policy import check_website_access
|
||||
import sys
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -937,7 +938,7 @@ if __name__ == "__main__":
|
|||
if not api_available:
|
||||
print("❌ No auxiliary vision model available")
|
||||
print("Configure a supported multimodal backend (OpenRouter, Nous, Codex, Anthropic, or a custom OpenAI-compatible endpoint).")
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
else:
|
||||
print("✅ Vision model available")
|
||||
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ from tools.managed_tool_gateway import (
|
|||
from tools.tool_backend_helpers import managed_nous_tools_enabled, prefers_gateway
|
||||
from tools.url_safety import is_safe_url
|
||||
from tools.website_policy import check_website_access
|
||||
import sys
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -2153,7 +2154,7 @@ if __name__ == "__main__":
|
|||
print(f"✅ Auxiliary model available: {default_summarizer_model}")
|
||||
|
||||
if not web_available:
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
print("🛠️ Web tools ready for use!")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue