mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-09 08:21:50 +00:00
chore: remove ~100 unused imports across 55 files (#3016)
Automated cleanup via pyflakes + autoflake with manual review.
Changes:
- Removed unused stdlib imports (os, sys, json, pathlib.Path, etc.)
- Removed unused typing imports (List, Dict, Any, Optional, Tuple, Set, etc.)
- Removed unused internal imports (hermes_cli.auth, hermes_cli.config, etc.)
- Fixed cli.py: removed 8 shadowed banner imports (imported from hermes_cli.banner
then immediately redefined locally — only build_welcome_banner is actually used)
- Added noqa comments to imports that appear unused but serve a purpose:
- Re-exports (gateway/session.py SessionResetPolicy, tools/terminal_tool.py
is_interrupted/_interrupt_event)
- SDK presence checks in try/except (daytona, fal_client, discord)
- Test mock targets (auxiliary_client.py Path, mcp_config.py get_hermes_home)
Zero behavioral changes. Full test suite passes (6162/6162, 2 pre-existing
streaming test failures unrelated to this change).
This commit is contained in:
parent
861624d4e9
commit
8bb1d15da4
55 changed files with 51 additions and 119 deletions
|
|
@ -23,7 +23,6 @@ import logging
|
|||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Set
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ a thin dispatcher that delegates to a platform-provided callback.
|
|||
"""
|
||||
|
||||
import json
|
||||
from typing import Dict, Any, List, Optional, Callable
|
||||
from typing import List, Optional, Callable
|
||||
|
||||
|
||||
# Maximum number of predefined choices the agent can offer.
|
||||
|
|
|
|||
|
|
@ -171,7 +171,6 @@ def _build_child_agent(
|
|||
model on OpenRouter while the parent runs on Nous Portal).
|
||||
"""
|
||||
from run_agent import AIAgent
|
||||
import model_tools
|
||||
|
||||
# When no explicit toolsets given, inherit from parent's enabled toolsets
|
||||
# so disabled tools (e.g. web) don't leak to subagents.
|
||||
|
|
|
|||
|
|
@ -27,11 +27,10 @@ Usage:
|
|||
|
||||
import os
|
||||
import re
|
||||
import json
|
||||
import difflib
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Optional, List, Dict, Any, Tuple
|
||||
from typing import Optional, List, Dict, Any
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@
|
|||
import errno
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import threading
|
||||
from typing import Optional
|
||||
from tools.file_operations import ShellFileOperations
|
||||
from agent.redact import redact_sensitive_text
|
||||
|
||||
|
|
@ -50,8 +48,8 @@ def _get_file_ops(task_id: str = "default") -> ShellFileOperations:
|
|||
from tools.terminal_tool import (
|
||||
_active_environments, _env_lock, _create_environment,
|
||||
_get_env_config, _last_activity, _start_cleanup_thread,
|
||||
_check_disk_usage_warning,
|
||||
_creation_locks, _creation_locks_lock,
|
||||
_creation_locks,
|
||||
_creation_locks_lock,
|
||||
)
|
||||
import time
|
||||
|
||||
|
|
|
|||
|
|
@ -416,7 +416,7 @@ def check_image_generation_requirements() -> bool:
|
|||
return False
|
||||
|
||||
# Check if fal_client is available
|
||||
import fal_client
|
||||
import fal_client # noqa: F401 — SDK presence check
|
||||
return True
|
||||
|
||||
except ImportError:
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import logging
|
|||
import os
|
||||
import platform
|
||||
import shlex
|
||||
import shutil
|
||||
import signal
|
||||
import subprocess
|
||||
import threading
|
||||
|
|
@ -44,7 +43,6 @@ import uuid
|
|||
_IS_WINDOWS = platform.system() == "Windows"
|
||||
from tools.environments.local import _find_shell, _sanitize_subprocess_env
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from hermes_cli.config import get_hermes_home
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Import chain (circular-import safe):
|
|||
|
||||
import json
|
||||
import logging
|
||||
from typing import Any, Callable, Dict, List, Optional, Set
|
||||
from typing import Callable, Dict, List, Optional, Set
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import uuid
|
|||
import logging
|
||||
from datetime import datetime
|
||||
import yaml
|
||||
from dataclasses import dataclass, field
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ async def _send_telegram(token, chat_id, message, media_files=None, thread_id=No
|
|||
else:
|
||||
# Reuse the gateway adapter's format_message for markdown→MarkdownV2
|
||||
try:
|
||||
from gateway.platforms.telegram import TelegramAdapter, _escape_mdv2, _strip_mdv2
|
||||
from gateway.platforms.telegram import TelegramAdapter, _strip_mdv2
|
||||
_adapter = TelegramAdapter.__new__(TelegramAdapter)
|
||||
formatted = _adapter.format_message(message)
|
||||
except Exception:
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ Flow:
|
|||
import asyncio
|
||||
import concurrent.futures
|
||||
import json
|
||||
import os
|
||||
import logging
|
||||
from typing import Dict, Any, List, Optional, Union
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import httpx
|
|||
import yaml
|
||||
|
||||
from tools.skills_guard import (
|
||||
ScanResult, scan_skill, should_allow_install, content_hash, TRUSTED_REPOS,
|
||||
ScanResult, content_hash, TRUSTED_REPOS,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import json
|
|||
import logging
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
import time
|
||||
import threading
|
||||
import atexit
|
||||
|
|
@ -48,7 +47,7 @@ logger = logging.getLogger(__name__)
|
|||
# The terminal tool polls this during command execution so it can kill
|
||||
# long-running subprocesses immediately instead of blocking until timeout.
|
||||
# ---------------------------------------------------------------------------
|
||||
from tools.interrupt import is_interrupted, _interrupt_event
|
||||
from tools.interrupt import is_interrupted, _interrupt_event # noqa: F401 — re-exported
|
||||
|
||||
|
||||
# =============================================================================
|
||||
|
|
@ -1232,7 +1231,7 @@ def check_terminal_requirements() -> bool:
|
|||
return True
|
||||
|
||||
elif env_type == "daytona":
|
||||
from daytona import Daytona
|
||||
from daytona import Daytona # noqa: F401 — SDK presence check
|
||||
return os.getenv("DAYTONA_API_KEY") is not None
|
||||
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -629,7 +629,6 @@ def stream_tts_to_speaker(
|
|||
if client is not None:
|
||||
try:
|
||||
sd = _import_sounddevice()
|
||||
import numpy as _np
|
||||
output_stream = sd.OutputStream(
|
||||
samplerate=24000, channels=1, dtype="int16",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ Usage:
|
|||
)
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import base64
|
||||
import json
|
||||
import logging
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import tempfile
|
|||
import threading
|
||||
import time
|
||||
import wave
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -710,7 +709,7 @@ def check_voice_requirements() -> Dict[str, Any]:
|
|||
``missing_packages``, and ``details``.
|
||||
"""
|
||||
# Determine STT provider availability
|
||||
from tools.transcription_tools import _get_provider, _load_stt_config, is_stt_enabled, _HAS_FASTER_WHISPER
|
||||
from tools.transcription_tools import _get_provider, _load_stt_config, is_stt_enabled
|
||||
stt_config = _load_stt_config()
|
||||
stt_enabled = is_stt_enabled(stt_config)
|
||||
stt_provider = _get_provider(stt_config)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue