chore: remove unused imports and dead locals (ruff F401, F841) (#17010)

Mechanical cleanup across 43 files — removes 46 unused imports
(F401) and 14 unused local variables (F841) detected by
`ruff check --select F401,F841`. Net: -49 lines.

Also fixes a latent NameError in rl_cli.py where `get_hermes_home()`
was called at module line 32 before its import at line 65 — the
module never imported successfully on main. The ruff audit surfaced
this because it correctly saw the symbol as imported-but-unused
(the call happened before the import ran); the fix moves the import
to the top of the file alongside other stdlib imports.

One `# noqa: F401` kept in hermes_cli/status.py for `subprocess`:
tests monkeypatch `hermes_cli.status.subprocess` as a regression
guard that systemctl isn't called on Termux, so the name must
exist at module scope even though the module body doesn't reference
it. Docstring explains the reason.

Also fixes an invalid `# noqa:` directive in
gateway/platforms/discord.py:308 that lacked a rule code.

Co-authored-by: teknium1 <teknium@users.noreply.github.com>
This commit is contained in:
Teknium
2026-04-28 06:46:45 -07:00
committed by GitHub
parent 3d8be2c617
commit 6085d7a93e
43 changed files with 28 additions and 77 deletions

View File

@@ -20,7 +20,6 @@ from __future__ import annotations
import asyncio
import json
import logging
import os
from typing import Any, Dict, Optional
from tools.registry import registry, tool_error

View File

@@ -25,7 +25,7 @@ import json
import logging
import threading
import time
from dataclasses import dataclass, field
from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Tuple
import websockets

View File

@@ -526,7 +526,6 @@ def _url_is_private(url: str) -> bool:
backend is configured, which will surface the DNS error naturally).
"""
try:
from tools.url_safety import is_safe_url
# is_safe_url returns False for private/loopback/link-local/CGNAT AND
# for DNS failures. We only want the private-network case here, so
# we parse + check the host shape as a DNS-failure sieve first.

View File

@@ -27,7 +27,6 @@ import time
from concurrent.futures import (
ThreadPoolExecutor,
TimeoutError as FuturesTimeoutError,
as_completed,
)
from typing import Any, Dict, List, Optional

View File

@@ -32,7 +32,6 @@ from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from typing import Optional, List, Dict, Any
from pathlib import Path
from hermes_constants import get_hermes_home
from tools.binary_extensions import BINARY_EXTENSIONS
from agent.file_safety import (

View File

@@ -7,7 +7,6 @@ import logging
import os
import threading
from pathlib import Path
from typing import Optional
from agent.file_safety import get_read_block_error
from tools.binary_extensions import has_binary_extension

View File

@@ -836,7 +836,6 @@ def transcribe_audio(file_path: str, model: Optional[str] = None) -> Dict[str, A
return _transcribe_mistral(file_path, model_name)
if provider == "xai":
xai_cfg = stt_config.get("xai", {})
# xAI Grok STT doesn't use a model parameter — pass through for logging
model_name = model or "grok-stt"
return _transcribe_xai(file_path, model_name)

View File

@@ -20,7 +20,7 @@ from __future__ import annotations
import logging
from pathlib import Path
from typing import TYPE_CHECKING, List, Optional, Tuple
from typing import List, Optional, Tuple
logger = logging.getLogger(__name__)
@@ -34,10 +34,6 @@ def _get_active_adapter():
return None
if TYPE_CHECKING:
from gateway.platforms.yuanbao import YuanbaoAdapter
# ---------------------------------------------------------------------------
# 角色标签
# ---------------------------------------------------------------------------
@@ -418,7 +414,7 @@ async def send_dm(
# Registry registration
# ---------------------------------------------------------------------------
from tools.registry import registry, tool_result, tool_error # noqa: E402
from tools.registry import registry, tool_result # noqa: E402
def _check_yuanbao():