mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-08 08:11:38 +00:00
chore: prune unused imports and duplicate import redefinitions
Remove unused imports (F401) and duplicate/shadowed import redefinitions (F811) across the codebase using ruff's safe autofixes. No behavioral changes -- imports only. - ~1400 safe autofixes applied across 644 files (net -1072 lines) - __init__.py re-exports preserved (excluded from F401 removal so public re-export surfaces stay intact) - Re-exports that are imported or monkeypatched by tests but look unused in their defining module are kept with explicit # noqa: F401 (gateway/run.py load_dotenv; run_agent re-exports from agent.message_sanitization, agent.context_compressor, agent.retry_utils, agent.prompt_builder, agent.process_bootstrap, agent.codex_responses_adapter) - Unsafe F841 (unused-variable) fixes deliberately skipped -- those can change behavior when the RHS has side effects - ruff lints remain disabled in pyproject.toml (only PLW1514 is selected); this is a one-time cleanup, not a config change Verification: - python -m compileall: clean - pytest --collect-only: all 27161 tests collect (zero import errors) - core entry points import clean (run_agent, model_tools, cli, toolsets, hermes_state, batch_runner, gateway) - static scan: every name any test imports directly from an edited module still resolves
This commit is contained in:
parent
a4d8f0f62a
commit
66827f8947
644 changed files with 254 additions and 1326 deletions
|
|
@ -18,7 +18,6 @@ churn accumulated ~20B per session_id until the process exited.
|
|||
These tests pin the new caps + prune hooks.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class TestReadTrackerCaps:
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ from tools.approval import (
|
|||
is_approved,
|
||||
load_permanent,
|
||||
prompt_dangerous_approval,
|
||||
submit_pending,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,6 @@ between slices, mirroring ``_wait_for_process`` in ``tools/environments/base.py`
|
|||
"""
|
||||
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
def _clear_approval_state():
|
||||
|
|
|
|||
|
|
@ -13,9 +13,6 @@ import pytest
|
|||
import tools.approval as approval_module
|
||||
from tools.approval import (
|
||||
check_all_command_guards,
|
||||
register_gateway_notify,
|
||||
unregister_gateway_notify,
|
||||
resolve_gateway_approval,
|
||||
set_current_session_key,
|
||||
clear_session,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@ Tests _wrap_command(), _extract_cwd_from_output(), _embed_stdin_heredoc(),
|
|||
init_session() failure handling, and the CWD marker contract.
|
||||
"""
|
||||
|
||||
import uuid
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from tools.environments.base import BaseEnvironment, _cwd_marker
|
||||
from tools.environments.base import BaseEnvironment
|
||||
|
||||
|
||||
class _TestableEnv(BaseEnvironment):
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
"""Tests for the Camofox browser backend."""
|
||||
|
||||
import json
|
||||
import os
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.browser_camofox import (
|
||||
camofox_back,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def _load_module():
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ for the full command timeout before surfacing a useless error.
|
|||
"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Covers the fallback logic in _get_session_info() when a cloud provider
|
|||
is configured but fails at runtime (issue #10883).
|
||||
"""
|
||||
import logging
|
||||
from unittest.mock import Mock, patch
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
import pytest
|
||||
|
|
|
|||
|
|
@ -9,9 +9,8 @@ These tests verify both sites are guarded.
|
|||
"""
|
||||
|
||||
import types
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
# ── helpers ────────────────────────────────────────────────────────────────
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ real browser, no real WebSocket. Real-CDP coverage lives in
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
"""Tests for browser_tool.py hardening: caching, security, thread safety, truncation."""
|
||||
|
||||
import inspect
|
||||
import os
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch, MagicMock, mock_open
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@
|
|||
daemons whose Python parent exited without cleaning up."""
|
||||
|
||||
import os
|
||||
import signal
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch, MagicMock
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ from __future__ import annotations
|
|||
import asyncio
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
|
@ -48,7 +47,6 @@ def chrome_cdp(request):
|
|||
Always launches with ``--site-per-process`` so cross-origin iframes
|
||||
become real OOPIFs (needed by the iframe interaction tests).
|
||||
"""
|
||||
import socket
|
||||
|
||||
# xdist worker_id is "master" in single-process mode or "gw0".."gwN" otherwise.
|
||||
# Under subprocess-per-file isolation there's no xdist, so we fall back
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ from tools.checkpoint_manager import (
|
|||
_project_meta_path,
|
||||
_touch_project,
|
||||
format_checkpoint_list,
|
||||
DEFAULT_EXCLUDES,
|
||||
CHECKPOINT_BASE,
|
||||
prune_checkpoints,
|
||||
maybe_auto_prune_checkpoints,
|
||||
store_status,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import threading
|
|||
import time
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def _clear_clarify_state():
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
import json
|
||||
from typing import List, Optional
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.clarify_tool import (
|
||||
clarify_tool,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import queue
|
|||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch, MagicMock, PropertyMock, mock_open
|
||||
from unittest.mock import patch, MagicMock, mock_open
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ def _force_local_terminal(monkeypatch):
|
|||
"""
|
||||
monkeypatch.setenv("TERMINAL_ENV", "local")
|
||||
import sys
|
||||
import time
|
||||
import threading
|
||||
import unittest
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
|
|
|||
|
|
@ -21,16 +21,13 @@ bytes. The child then fails to import with a SyntaxError:
|
|||
"""
|
||||
|
||||
import os
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
import unittest.mock as mock
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.code_execution_tool import (
|
||||
_SAFE_ENV_PREFIXES,
|
||||
_SECRET_SUBSTRINGS,
|
||||
_WINDOWS_ESSENTIAL_ENV_VARS,
|
||||
_scrub_child_env,
|
||||
|
|
|
|||
|
|
@ -10,12 +10,9 @@ from tools.approval import (
|
|||
approve_session,
|
||||
check_all_command_guards,
|
||||
is_approved,
|
||||
set_current_session_key,
|
||||
reset_current_session_key,
|
||||
)
|
||||
|
||||
# Ensure the module is importable so we can patch it
|
||||
import tools.tirith_security
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from __future__ import annotations
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
from typing import Any, Dict, List
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ from __future__ import annotations
|
|||
import base64
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ return ``None`` instead of the default — calling ``.lower()`` on that raises
|
|||
"""
|
||||
|
||||
from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
|
||||
# ── TTS tool ──────────────────────────────────────────────────────────────
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
"""Tests for credential file passthrough and skills directory mounting."""
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
"""Tests for approvals.cron_mode — configurable approval behavior for cron jobs."""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
import tools.approval as approval_module
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import json
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
|
||||
from tools.cronjob_tools import (
|
||||
_scan_cron_prompt,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ This file tests that the tool surfaces:
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import threading
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import MagicMock, patch, PropertyMock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ Run with: python -m pytest tests/test_delegate.py -v
|
|||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import unittest
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
"""Tests for composite toolset expansion in delegate_task intersection."""
|
||||
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from tools.delegate_tool import _expand_parent_toolsets
|
||||
|
||||
|
|
|
|||
|
|
@ -16,12 +16,10 @@ These tests pin:
|
|||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ parent's enabled_toolsets, it can escalate privileges by requesting
|
|||
arbitrary toolsets.
|
||||
"""
|
||||
|
||||
from unittest.mock import MagicMock, patch
|
||||
from types import SimpleNamespace
|
||||
|
||||
from tools.delegate_tool import _strip_blocked_tools
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
"""Tests for the Discord server introspection and management tool."""
|
||||
|
||||
import json
|
||||
import os
|
||||
import urllib.error
|
||||
from io import BytesIO
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
|
@ -14,7 +13,6 @@ from tools.discord_tool import (
|
|||
_ADMIN_ACTIONS,
|
||||
_CORE_ACTIONS,
|
||||
_available_actions,
|
||||
_build_schema,
|
||||
_channel_type_name,
|
||||
_detect_capabilities,
|
||||
_discord_request,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import logging
|
||||
from io import StringIO
|
||||
import subprocess
|
||||
import sys
|
||||
import types
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -198,7 +198,6 @@ class TestTerminalIntegration:
|
|||
def test_make_run_env_blocklist_override_rejected(self):
|
||||
"""_make_run_env must NOT expose a blocklisted var to subprocess env
|
||||
even after a skill attempts to register it via passthrough."""
|
||||
import os
|
||||
from tools.environments.local import (
|
||||
_make_run_env,
|
||||
_HERMES_PROVIDER_ENV_BLOCKLIST,
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ from unittest.mock import MagicMock
|
|||
|
||||
from tools.file_operations import (
|
||||
_is_write_denied,
|
||||
WRITE_DENIED_PATHS,
|
||||
WRITE_DENIED_PREFIXES,
|
||||
ReadResult,
|
||||
WriteResult,
|
||||
PatchResult,
|
||||
|
|
@ -17,8 +15,6 @@ from tools.file_operations import (
|
|||
SearchMatch,
|
||||
LintResult,
|
||||
ShellFileOperations,
|
||||
BINARY_EXTENSIONS,
|
||||
IMAGE_EXTENSIONS,
|
||||
MAX_LINE_LENGTH,
|
||||
normalize_read_pagination,
|
||||
normalize_search_pagination,
|
||||
|
|
|
|||
|
|
@ -17,10 +17,7 @@ Fix: _exec() now prefers the LIVE ``env.cwd`` over the init-time
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.file_operations import ShellFileOperations
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ from tools.file_tools import (
|
|||
_is_blocked_device,
|
||||
_invalidate_dedup_for_path,
|
||||
_READ_DEDUP_STATUS_MESSAGE,
|
||||
_get_max_read_chars,
|
||||
_DEFAULT_MAX_READ_CHARS,
|
||||
_read_tracker,
|
||||
notify_other_tool_call,
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@ import logging
|
|||
import os
|
||||
import signal
|
||||
import tarfile
|
||||
import time
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, call, patch
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,7 @@ import logging
|
|||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from tools.file_tools import (
|
||||
READ_FILE_SCHEMA,
|
||||
WRITE_FILE_SCHEMA,
|
||||
PATCH_SCHEMA,
|
||||
SEARCH_FILES_SCHEMA,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,12 +13,10 @@ import pytest
|
|||
|
||||
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
|
||||
|
||||
|
|
@ -388,7 +386,6 @@ class TestExpandPath:
|
|||
# The path should be returned as-is (no expansion).
|
||||
assert result == malicious
|
||||
# Verify the injected command did NOT execute
|
||||
import os
|
||||
assert not os.path.exists("/tmp/_hermes_injection_test")
|
||||
|
||||
def test_tilde_username_with_subpath(self, ops):
|
||||
|
|
|
|||
|
|
@ -6,12 +6,10 @@ gateway /yolo, approvals.mode=off, or cron approve mode.
|
|||
|
||||
Inspired by Mercury Agent's permission-hardened blocklist.
|
||||
"""
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.approval import (
|
||||
DANGEROUS_PATTERNS,
|
||||
HARDLINE_PATTERNS,
|
||||
check_all_command_guards,
|
||||
check_dangerous_command,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
"""Tests for delegate heartbeat stale threshold configuration."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class TestHeartbeatStaleThresholds:
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ This caused quarantined skills (.hub/quarantine/) to appear as installed.
|
|||
Now uses Path.parts which is platform-independent.
|
||||
"""
|
||||
|
||||
import os
|
||||
from pathlib import Path, PurePosixPath, PureWindowsPath
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _old_filter_matches(path_str: str) -> bool:
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class TestPreToolCheck:
|
|||
|
||||
def test_all_tools_skipped_when_interrupted(self):
|
||||
"""Mock an interrupted agent and verify no tools execute."""
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
# Build a fake assistant_message with 3 tool calls
|
||||
tc1 = MagicMock()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ Verifies:
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
@ -26,7 +25,6 @@ def test_kanban_tools_hidden_without_env_var(monkeypatch, tmp_path):
|
|||
home.mkdir()
|
||||
monkeypatch.setenv("HERMES_HOME", str(home))
|
||||
|
||||
import tools.kanban_tools # ensure registered
|
||||
from tools.registry import invalidate_check_fn_cache, registry
|
||||
from toolsets import resolve_toolset
|
||||
|
||||
|
|
@ -46,7 +44,6 @@ def test_kanban_tools_visible_with_env_var(monkeypatch, tmp_path):
|
|||
home.mkdir()
|
||||
monkeypatch.setenv("HERMES_HOME", str(home))
|
||||
|
||||
import tools.kanban_tools # ensure registered
|
||||
from tools.registry import invalidate_check_fn_cache, registry
|
||||
from toolsets import resolve_toolset
|
||||
|
||||
|
|
@ -70,7 +67,6 @@ def test_kanban_worker_env_overrides_profile_toolset_filter(monkeypatch, tmp_pat
|
|||
home.mkdir()
|
||||
monkeypatch.setenv("HERMES_HOME", str(home))
|
||||
|
||||
import tools.kanban_tools # ensure registered
|
||||
from model_tools import _clear_tool_defs_cache, get_tool_definitions
|
||||
from tools.registry import invalidate_check_fn_cache
|
||||
|
||||
|
|
@ -100,7 +96,6 @@ def test_worker_with_kanban_toolset_still_hides_board_routing(monkeypatch, tmp_p
|
|||
(home / "config.yaml").write_text("toolsets:\n - kanban\n")
|
||||
monkeypatch.setenv("HERMES_HOME", str(home))
|
||||
|
||||
import tools.kanban_tools # ensure registered
|
||||
from tools.registry import invalidate_check_fn_cache, registry
|
||||
from toolsets import resolve_toolset
|
||||
|
||||
|
|
@ -125,7 +120,6 @@ def test_kanban_tools_visible_with_toolset_config(monkeypatch, tmp_path):
|
|||
(home / "config.yaml").write_text("toolsets:\n - kanban\n")
|
||||
monkeypatch.setenv("HERMES_HOME", str(home))
|
||||
|
||||
import tools.kanban_tools # ensure registered
|
||||
from tools.registry import invalidate_check_fn_cache, registry
|
||||
from toolsets import resolve_toolset
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ call is mocked — we never actually shell out during unit tests.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Iterator
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ See issue #507 (Roo Code deep-dive, item 2c).
|
|||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ reasoning fields when content is empty.
|
|||
|
||||
import asyncio
|
||||
import types
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ of the backgrounded service (indefinitely for a uvicorn server).
|
|||
The fix switches ``_drain()`` to select()-based non-blocking reads and
|
||||
stops draining shortly after bash exits even if the pipe hasn't EOF'd.
|
||||
"""
|
||||
import json
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,8 @@ and ``os.path.isdir`` so the MSYS path tests as "missing" exactly like
|
|||
on the real OS.
|
||||
"""
|
||||
|
||||
import os
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.environments import local as local_mod
|
||||
from tools.environments.local import (
|
||||
|
|
|
|||
|
|
@ -161,7 +161,6 @@ def test_wait_for_process_kills_subprocess_on_keyboardinterrupt():
|
|||
# way CPython's signal machinery would. We use ctypes.PyThreadState_SetAsyncExc
|
||||
# which is how signal delivery to non-main threads is simulated.
|
||||
import ctypes
|
||||
import sys as _sys
|
||||
# py-thread-state exception targets need the ident, not the Thread
|
||||
tid = t.ident
|
||||
assert tid is not None
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import pytest
|
|||
from tools.environments.local import (
|
||||
LocalEnvironment,
|
||||
_prepend_shell_init,
|
||||
_read_terminal_shell_init_config,
|
||||
_resolve_shell_init_files,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import json
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ from __future__ import annotations
|
|||
import asyncio
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
async def _hanging_run(self, cfg):
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ Covers:
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
|
|
|||
|
|
@ -7,11 +7,7 @@ nothing after the colon, making debugging impossible.
|
|||
Fix: ``_exc_str()`` falls back to ``repr(exc)`` when ``str(exc)`` is empty.
|
||||
"""
|
||||
|
||||
import json
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.mcp_tool import _exc_str, _sanitize_error
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ from __future__ import annotations
|
|||
|
||||
import base64
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def _png_bytes():
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ import os
|
|||
import stat
|
||||
import sys
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch, MagicMock, AsyncMock
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
"""Tests for MCP stability fixes — event loop handler, PID tracking, shutdown robustness."""
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
import signal
|
||||
import threading
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -227,7 +224,7 @@ class TestMCPInitialConnectionRetry:
|
|||
|
||||
def test_initial_connect_retry_succeeds_on_second_attempt(self):
|
||||
"""Server succeeds after one transient initial failure."""
|
||||
from tools.mcp_tool import MCPServerTask, _MAX_INITIAL_CONNECT_RETRIES
|
||||
from tools.mcp_tool import MCPServerTask
|
||||
|
||||
call_count = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ All tests use mocks -- no real MCP servers or subprocesses are started.
|
|||
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
from types import SimpleNamespace
|
||||
|
|
@ -1770,7 +1769,7 @@ class TestConfigurableTimeouts:
|
|||
|
||||
def test_timeout_passed_to_handler(self):
|
||||
"""The tool handler uses the server's configured timeout."""
|
||||
from tools.mcp_tool import _make_tool_handler, _servers, MCPServerTask
|
||||
from tools.mcp_tool import _make_tool_handler, _servers
|
||||
|
||||
mock_session = MagicMock()
|
||||
mock_session.call_tool = AsyncMock(
|
||||
|
|
@ -2225,8 +2224,6 @@ class TestUtilityToolRegistration:
|
|||
# SamplingHandler tests
|
||||
# ===========================================================================
|
||||
|
||||
import math
|
||||
import time
|
||||
|
||||
class _CompatType:
|
||||
def __init__(self, **kwargs):
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
import asyncio
|
||||
import os
|
||||
import sys
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.mcp_tool import MCPServerTask, _format_connect_error, _resolve_stdio_command, _MCP_AVAILABLE
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ affected MCP server failed until the gateway was manually restarted.
|
|||
"""
|
||||
import json
|
||||
import threading
|
||||
import time
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ from __future__ import annotations
|
|||
from types import SimpleNamespace
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def _make_init_result(*, resources: bool, prompts: bool):
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from tools.memory_tool import (
|
|||
MemoryStore,
|
||||
memory_tool,
|
||||
_scan_memory_content,
|
||||
ENTRY_DELIMITER,
|
||||
MEMORY_SCHEMA,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ import asyncio
|
|||
import base64
|
||||
import io
|
||||
import tarfile
|
||||
from pathlib import Path
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -10,11 +10,9 @@ Covers:
|
|||
|
||||
import json
|
||||
import os
|
||||
import queue
|
||||
import time
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
from tools.process_registry import (
|
||||
ProcessRegistry,
|
||||
|
|
|
|||
|
|
@ -7,14 +7,12 @@ import subprocess
|
|||
import sys
|
||||
import time
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from tools.environments.local import _HERMES_PROVIDER_ENV_FORCE_PREFIX
|
||||
from tools.process_registry import (
|
||||
ProcessRegistry,
|
||||
ProcessSession,
|
||||
MAX_OUTPUT_CHARS,
|
||||
FINISHED_TTL_SECONDS,
|
||||
MAX_PROCESSES,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import os
|
|||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class TestResolvePath:
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ Fix: _search_files (find) and _search_with_grep both now exclude hidden
|
|||
directories, matching ripgrep's default behavior.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import asyncio
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
|
|
@ -40,7 +39,6 @@ from tools.send_message_tool import (
|
|||
# and provide a thin ``_send_discord(token, ...)`` shim that mirrors the
|
||||
# pre-migration signature so the existing test bodies keep working.
|
||||
from plugins.platforms.discord.adapter import (
|
||||
_DISCORD_CHANNEL_TYPE_PROBE_CACHE,
|
||||
_derive_forum_thread_name,
|
||||
_probe_is_forum_cached,
|
||||
_remember_channel_is_forum,
|
||||
|
|
@ -1517,7 +1515,6 @@ class TestSendMatrixUrlEncoding:
|
|||
|
||||
def test_room_id_is_percent_encoded_in_url(self):
|
||||
"""Matrix room IDs with ! and : are percent-encoded in the PUT URL."""
|
||||
import aiohttp
|
||||
|
||||
mock_resp = MagicMock()
|
||||
mock_resp.status = 200
|
||||
|
|
@ -1894,10 +1891,6 @@ class TestForumProbeCache:
|
|||
discord_adapter._DISCORD_CHANNEL_TYPE_PROBE_CACHE.clear()
|
||||
|
||||
def test_cache_round_trip(self):
|
||||
from plugins.platforms.discord.adapter import (
|
||||
_probe_is_forum_cached,
|
||||
_remember_channel_is_forum,
|
||||
)
|
||||
assert _probe_is_forum_cached("xyz") is None
|
||||
_remember_channel_is_forum("xyz", True)
|
||||
assert _probe_is_forum_cached("xyz") is True
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import asyncio
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
from unittest.mock import MagicMock, AsyncMock, patch
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
"""Test that skill_view registers required env vars in the passthrough registry."""
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
"""Tests for skill fuzzy patching via tools.fuzzy_match."""
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ from tools.skill_manager_tool import (
|
|||
_validate_category,
|
||||
_validate_frontmatter,
|
||||
_validate_file_path,
|
||||
_find_skill,
|
||||
_resolve_skill_dir,
|
||||
_create_skill,
|
||||
_edit_skill,
|
||||
_patch_skill,
|
||||
|
|
@ -21,8 +19,6 @@ from tools.skill_manager_tool import (
|
|||
_write_file,
|
||||
_remove_file,
|
||||
skill_manage,
|
||||
VALID_NAME_RE,
|
||||
ALLOWED_SUBDIRS,
|
||||
MAX_NAME_LENGTH,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import contextvars
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,15 +6,11 @@ Hand-placed and hub-installed skills have no hard limit.
|
|||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.skill_manager_tool import (
|
||||
MAX_SKILL_CONTENT_CHARS,
|
||||
MAX_SKILL_FILE_BYTES,
|
||||
_validate_content_size,
|
||||
skill_manage,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ def test_agent_created_skips_archive_and_hub_dirs(skills_home):
|
|||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_archive_skill_moves_directory(skills_home):
|
||||
from tools.skill_usage import archive_skill, get_record, STATE_ARCHIVED
|
||||
from tools.skill_usage import archive_skill, get_record
|
||||
skills_dir = skills_home / "skills"
|
||||
skill_dir = _write_skill(skills_dir, "old-skill")
|
||||
assert skill_dir.exists()
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ reading arbitrary files (e.g., ~/.hermes/.env) via path traversal.
|
|||
|
||||
import json
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from tools.skills_tool import skill_view
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
"""Tests for tools.skills_ast_audit — opt-in AST diagnostic scanner."""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from tools.skills_ast_audit import ast_scan_path, format_ast_report
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
"""Tests for tools/skills_guard.py - security scanner for skills."""
|
||||
|
||||
import os
|
||||
import stat
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
|
|
@ -33,8 +31,6 @@ from tools.skills_guard import (
|
|||
_resolve_trust_level,
|
||||
_check_structure,
|
||||
_unicode_char_name,
|
||||
INSTALL_POLICY,
|
||||
INVISIBLE_CHARS,
|
||||
MAX_FILE_COUNT,
|
||||
MAX_SINGLE_FILE_KB,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
"""Tests for tools/skills_hub.py — source adapters, lock file, taps, dedup logic."""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
import httpx
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ from tools.skills_sync import (
|
|||
sync_skills,
|
||||
reset_bundled_skill,
|
||||
restore_official_optional_skill,
|
||||
MANIFEST_FILE,
|
||||
SKILLS_DIR,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ for 'axolotl/' because the string prefix matched. Now uses
|
|||
Path.is_relative_to() which handles directory boundaries correctly.
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import asyncio
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from unittest.mock import AsyncMock, MagicMock, call, patch
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ The rewriter fixes this by wrapping the tail in a brace group —
|
|||
the current shell. No subshell fork, no wait.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.terminal_tool import _rewrite_compound_background as rewrite
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ Ensures that foreground commands with timeout > FOREGROUND_MAX_TIMEOUT
|
|||
are rejected with an error suggesting background=true.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
|
||||
|
|
@ -123,7 +122,7 @@ class TestForegroundTimeoutCap:
|
|||
Only the model's explicit timeout parameter triggers rejection,
|
||||
not the user's configured default.
|
||||
"""
|
||||
from tools.terminal_tool import terminal_tool, FOREGROUND_MAX_TIMEOUT
|
||||
from tools.terminal_tool import terminal_tool
|
||||
|
||||
# User configured TERMINAL_TIMEOUT=900 in their env
|
||||
with patch("tools.terminal_tool._get_env_config",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import importlib
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
|
||||
terminal_tool_module = importlib.import_module("tools.terminal_tool")
|
||||
|
||||
|
|
|
|||
|
|
@ -1048,7 +1048,7 @@ class TestDiskFailureMarker:
|
|||
|
||||
def test_cosign_missing_disk_marker_allows_retry(self):
|
||||
"""Disk marker with cosign_missing reason allows retry when cosign appears."""
|
||||
from tools.tirith_security import _resolve_tirith_path, _INSTALL_FAILED
|
||||
from tools.tirith_security import _resolve_tirith_path
|
||||
_tirith_mod._resolved_path = None
|
||||
|
||||
# _is_install_failed_on_disk sees "cosign_missing" + cosign on PATH → returns False
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ from unittest.mock import MagicMock, patch
|
|||
|
||||
from tools.budget_config import (
|
||||
DEFAULT_RESULT_SIZE_CHARS,
|
||||
DEFAULT_TURN_BUDGET_CHARS,
|
||||
DEFAULT_PREVIEW_SIZE_CHARS,
|
||||
BudgetConfig,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,12 +4,10 @@ Tests cover provider selection, config loading, validation, and transcription
|
|||
dispatch. All external dependencies (faster_whisper, openai) are mocked.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import MagicMock, patch, mock_open
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
@ -109,7 +107,6 @@ class TestValidateAudioFile:
|
|||
assert _validate_audio_file(str(f)) is None
|
||||
|
||||
def test_too_large(self, tmp_path):
|
||||
import stat as stat_mod
|
||||
f = tmp_path / "big.ogg"
|
||||
f.write_bytes(b"x")
|
||||
from tools.transcription_tools import _validate_audio_file, MAX_FILE_SIZE
|
||||
|
|
@ -292,7 +289,7 @@ class TestNormalizeLocalModel:
|
|||
|
||||
def test_local_transcribe_normalises_model(self):
|
||||
"""transcribe_audio with local provider must not pass 'whisper-1' to WhisperModel."""
|
||||
import tempfile, os
|
||||
import os
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
with tempfile.NamedTemporaryFile(suffix=".ogg", delete=False) as f:
|
||||
|
|
|
|||
|
|
@ -19,15 +19,11 @@ identically on Linux, macOS, and Windows (with minor quoting differences).
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import wave
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.transcription_tools import (
|
||||
BUILTIN_STT_PROVIDERS,
|
||||
|
|
@ -39,12 +35,9 @@ from tools.transcription_tools import (
|
|||
_get_command_stt_timeout,
|
||||
_get_named_stt_provider_config,
|
||||
_has_any_command_stt_provider,
|
||||
_is_command_stt_provider_config,
|
||||
_iter_command_stt_providers,
|
||||
_quote_command_stt_placeholder,
|
||||
_render_command_stt_template,
|
||||
_resolve_command_stt_provider_config,
|
||||
_shell_quote_context_stt,
|
||||
_transcribe_command_stt,
|
||||
transcribe_audio,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -14,10 +14,8 @@ differences) Windows.
|
|||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
|
|
|||
|
|
@ -6,12 +6,9 @@ MiniMax allows 10000, and ElevenLabs allows 5000-40000 depending on model.
|
|||
"""
|
||||
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.tts_tool import (
|
||||
ELEVENLABS_MODEL_MAX_TEXT_LENGTH,
|
||||
FALLBACK_MAX_TEXT_LENGTH,
|
||||
PROVIDER_MAX_TEXT_LENGTH,
|
||||
_resolve_max_text_length,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ without requiring the ``piper-tts`` package to actually be installed
|
|||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
|
|
|||
|
|
@ -2,20 +2,14 @@
|
|||
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Awaitable
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.vision_tools import (
|
||||
_detect_video_mime_type,
|
||||
_video_to_base64_data_url,
|
||||
_handle_video_analyze,
|
||||
_MAX_VIDEO_BASE64_BYTES,
|
||||
_VIDEO_MIME_TYPES,
|
||||
_VIDEO_SIZE_WARN_BYTES,
|
||||
video_analyze_tool,
|
||||
VIDEO_ANALYZE_SCHEMA,
|
||||
)
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue