Skip to content

Commit ac23894

Browse files
teknium1Aurora
authored andcommitted
chore: remove ~100 unused imports across 55 files (NousResearch#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).
1 parent b3cb287 commit ac23894

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+51
-119
lines changed

acp_adapter/events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import asyncio
1111
import json
1212
import logging
13-
from collections import defaultdict, deque
13+
from collections import deque
1414
from typing import Any, Callable, Deque, Dict
1515

1616
import acp

acp_adapter/permissions.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@
55
import asyncio
66
import logging
77
from concurrent.futures import TimeoutError as FutureTimeout
8-
from typing import Any, Callable, Optional
8+
from typing import Callable
99

1010
from acp.schema import (
1111
AllowedOutcome,
12-
DeniedOutcome,
1312
PermissionOption,
14-
RequestPermissionRequest,
15-
SelectedPermissionOutcome,
1613
)
1714

1815
logger = logging.getLogger(__name__)

agent/auxiliary_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import os
4242
import threading
4343
import time
44-
from pathlib import Path
44+
from pathlib import Path # noqa: F401 — used by test mocks
4545
from types import SimpleNamespace
4646
from typing import Any, Dict, List, Optional, Tuple
4747

agent/context_compressor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"""
1515

1616
import logging
17-
import os
1817
from typing import Any, Dict, List, Optional
1918

2019
from agent.auxiliary_client import call_llm

cli.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,8 @@ def load_cli_config() -> Dict[str, Any]:
458458
from model_tools import get_tool_definitions, get_toolset_for_tool
459459

460460
# Extracted CLI modules (Phase 3)
461-
from hermes_cli.banner import (
462-
cprint as _cprint, _GOLD, _BOLD, _DIM, _RST,
463-
HERMES_AGENT_LOGO, HERMES_CADUCEUS, COMPACT_BANNER,
464-
build_welcome_banner,
465-
)
466-
from hermes_cli.commands import COMMANDS, SlashCommandCompleter, SlashCommandAutoSuggest
467-
from hermes_cli import callbacks as _callbacks
461+
from hermes_cli.banner import build_welcome_banner
462+
from hermes_cli.commands import SlashCommandCompleter, SlashCommandAutoSuggest
468463
from toolsets import get_all_toolsets, get_toolset_info, validate_toolset
469464

470465
# Cron job system for scheduled tasks (execution is handled by the gateway)
@@ -2341,7 +2336,7 @@ def _handle_rollback_command(self, command: str):
23412336
/rollback diff <N> — preview changes since checkpoint N
23422337
/rollback <N> <file> — restore a single file from checkpoint N
23432338
"""
2344-
from tools.checkpoint_manager import CheckpointManager, format_checkpoint_list
2339+
from tools.checkpoint_manager import format_checkpoint_list
23452340

23462341
if not hasattr(self, 'agent') or not self.agent:
23472342
print(" No active agent session.")
@@ -2541,7 +2536,7 @@ def _preprocess_images_with_vision(self, text: str, images: list) -> str:
25412536
def _show_tool_availability_warnings(self):
25422537
"""Show warnings about disabled tools due to missing API keys."""
25432538
try:
2544-
from model_tools import check_tool_availability, TOOLSET_REQUIREMENTS
2539+
from model_tools import check_tool_availability
25452540

25462541
available, unavailable = check_tool_availability()
25472542

@@ -4134,7 +4129,6 @@ def _try_launch_chrome_debug(port: int, system: str) -> bool:
41344129
def _handle_browser_command(self, cmd: str):
41354130
"""Handle /browser connect|disconnect|status — manage live Chrome CDP connection."""
41364131
import platform as _plat
4137-
import subprocess as _sp
41384132

41394133
parts = cmd.strip().split(None, 1)
41404134
sub = parts[1].lower().strip() if len(parts) > 1 else "status"
@@ -4636,7 +4630,7 @@ def _reload_mcp(self):
46364630
sees the updated tools on the next turn.
46374631
"""
46384632
try:
4639-
from tools.mcp_tool import shutdown_mcp_servers, discover_mcp_tools, _load_mcp_config, _servers, _lock
4633+
from tools.mcp_tool import shutdown_mcp_servers, discover_mcp_tools, _servers, _lock
46404634

46414635
# Capture old server names
46424636
with _lock:
@@ -4956,7 +4950,6 @@ def _voice_speak_response(self, text: str):
49564950
try:
49574951
from tools.tts_tool import text_to_speech_tool
49584952
from tools.voice_mode import play_audio_file
4959-
import json
49604953
import re
49614954

49624955
# Strip markdown and non-speech content for cleaner TTS
@@ -6530,8 +6523,7 @@ def _get_model_completer_info() -> dict:
65306523
"""Return provider/model info for /model autocomplete."""
65316524
try:
65326525
from hermes_cli.models import (
6533-
_PROVIDER_LABELS, _PROVIDER_MODELS, normalize_provider,
6534-
provider_model_ids,
6526+
_PROVIDER_LABELS, normalize_provider, provider_model_ids,
65356527
)
65366528
current = getattr(cli_ref, "provider", None) or getattr(cli_ref, "requested_provider", "openrouter")
65376529
current = normalize_provider(current)

cron/scheduler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import msvcrt
2525
except ImportError:
2626
msvcrt = None
27-
from datetime import datetime
2827
from pathlib import Path
2928
from typing import Optional
3029

gateway/channel_directory.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import json
1010
import logging
1111
from datetime import datetime
12-
from pathlib import Path
1312
from typing import Any, Dict, List, Optional
1413

1514
from hermes_cli.config import get_hermes_home
@@ -90,7 +89,7 @@ def _build_discord(adapter) -> List[Dict[str, str]]:
9089
return channels
9190

9291
try:
93-
import discord as _discord
92+
import discord as _discord # noqa: F401 — SDK presence check
9493
except ImportError:
9594
return channels
9695

@@ -119,7 +118,6 @@ def _build_slack(adapter) -> List[Dict[str, str]]:
119118
return _build_from_sessions("slack")
120119

121120
try:
122-
import asyncio
123121
from tools.send_message_tool import _send_slack # noqa: F401
124122
# Use the Slack Web API directly if available
125123
except Exception:

gateway/delivery.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from datetime import datetime
1414
from dataclasses import dataclass
1515
from typing import Dict, List, Optional, Any, Union
16-
from enum import Enum
1716

1817
from hermes_cli.config import get_hermes_home
1918

gateway/hooks.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
import asyncio
2323
import importlib.util
24-
import os
25-
from pathlib import Path
2624
from typing import Any, Callable, Dict, List, Optional
2725

2826
import yaml

gateway/mirror.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import json
1313
import logging
1414
from datetime import datetime
15-
from pathlib import Path
1615
from typing import Optional
1716

1817
from hermes_cli.config import get_hermes_home

0 commit comments

Comments
 (0)