From 8e1c266f78d56fe3736557d63f0157bad5f7360d Mon Sep 17 00:00:00 2001 From: Alexander Whitestone Date: Mon, 23 Mar 2026 18:29:51 -0400 Subject: [PATCH] fix: remove unused imports and fix formatting (lint) --- src/infrastructure/hands/git.py | 14 +++++++---- tests/dashboard/test_daily_run.py | 13 ++++------- tests/infrastructure/test_chat_store.py | 6 +---- tests/infrastructure/test_router_cascade.py | 4 +--- tests/unit/test_vassal_agent_health.py | 26 +++++---------------- tests/unit/test_vassal_dispatch.py | 4 ++-- 6 files changed, 25 insertions(+), 42 deletions(-) diff --git a/src/infrastructure/hands/git.py b/src/infrastructure/hands/git.py index f62cc9c3..e2173ac9 100644 --- a/src/infrastructure/hands/git.py +++ b/src/infrastructure/hands/git.py @@ -72,7 +72,9 @@ class GitHand: return False async def _exec_subprocess( - self, args: str, timeout: int, + self, + args: str, + timeout: int, ) -> tuple[bytes, bytes, int]: """Run git as a subprocess, return (stdout, stderr, returncode). @@ -87,7 +89,8 @@ class GitHand: ) try: stdout, stderr = await asyncio.wait_for( - proc.communicate(), timeout=timeout, + proc.communicate(), + timeout=timeout, ) except TimeoutError: proc.kill() @@ -151,7 +154,8 @@ class GitHand: try: stdout_bytes, stderr_bytes, returncode = await self._exec_subprocess( - args, effective_timeout, + args, + effective_timeout, ) except TimeoutError: latency = (time.time() - start) * 1000 @@ -182,7 +186,9 @@ class GitHand: ) return self._parse_output( - command, stdout_bytes, stderr_bytes, + command, + stdout_bytes, + stderr_bytes, returncode=returncode, latency_ms=(time.time() - start) * 1000, ) diff --git a/tests/dashboard/test_daily_run.py b/tests/dashboard/test_daily_run.py index d010b502..6625a93a 100644 --- a/tests/dashboard/test_daily_run.py +++ b/tests/dashboard/test_daily_run.py @@ -3,13 +3,9 @@ from __future__ import annotations import json -import os from datetime import UTC, datetime, timedelta -from pathlib import Path from unittest.mock import MagicMock, patch -from urllib.error import HTTPError, URLError - -import pytest +from urllib.error import URLError from dashboard.routes.daily_run import ( DEFAULT_CONFIG, @@ -25,7 +21,6 @@ from dashboard.routes.daily_run import ( _load_cycle_data, ) - # --------------------------------------------------------------------------- # _load_config # --------------------------------------------------------------------------- @@ -42,7 +37,9 @@ def test_load_config_returns_defaults(): def test_load_config_merges_file_orchestrator_section(tmp_path): config_file = tmp_path / "daily_run.json" config_file.write_text( - json.dumps({"orchestrator": {"repo_slug": "custom/repo", "gitea_api": "http://custom:3000/api/v1"}}) + json.dumps( + {"orchestrator": {"repo_slug": "custom/repo", "gitea_api": "http://custom:3000/api/v1"}} + ) ) with patch("dashboard.routes.daily_run.CONFIG_PATH", config_file): config = _load_config() @@ -365,7 +362,7 @@ def test_load_cycle_data_skips_invalid_json_lines(tmp_path): now = datetime.now(UTC) recent_ts = (now - timedelta(days=1)).isoformat() retro_file.write_text( - f'not valid json\n{json.dumps({"timestamp": recent_ts, "success": True})}\n' + f"not valid json\n{json.dumps({'timestamp': recent_ts, 'success': True})}\n" ) with patch("dashboard.routes.daily_run.REPO_ROOT", tmp_path): diff --git a/tests/infrastructure/test_chat_store.py b/tests/infrastructure/test_chat_store.py index 0b50f628..0c40ba7e 100644 --- a/tests/infrastructure/test_chat_store.py +++ b/tests/infrastructure/test_chat_store.py @@ -1,12 +1,8 @@ """Unit tests for infrastructure.chat_store module.""" import threading -from pathlib import Path - -import pytest - -from infrastructure.chat_store import MAX_MESSAGES, Message, MessageLog, _get_conn +from infrastructure.chat_store import Message, MessageLog, _get_conn # --------------------------------------------------------------------------- # Message dataclass diff --git a/tests/infrastructure/test_router_cascade.py b/tests/infrastructure/test_router_cascade.py index aaa79bbc..0d282ba6 100644 --- a/tests/infrastructure/test_router_cascade.py +++ b/tests/infrastructure/test_router_cascade.py @@ -1416,9 +1416,7 @@ class TestFilterProviders: def test_frontier_required_no_anthropic_raises(self): router = CascadeRouter(config_path=Path("/nonexistent")) - router.providers = [ - Provider(name="ollama-p", type="ollama", enabled=True, priority=1) - ] + router.providers = [Provider(name="ollama-p", type="ollama", enabled=True, priority=1)] with pytest.raises(RuntimeError, match="No Anthropic provider configured"): router._filter_providers("frontier_required") diff --git a/tests/unit/test_vassal_agent_health.py b/tests/unit/test_vassal_agent_health.py index 275078bc..5e337c95 100644 --- a/tests/unit/test_vassal_agent_health.py +++ b/tests/unit/test_vassal_agent_health.py @@ -72,9 +72,7 @@ def test_report_any_stuck(): def test_report_not_any_stuck(): - report = AgentHealthReport( - agents=[AgentStatus(agent="claude"), AgentStatus(agent="kimi")] - ) + report = AgentHealthReport(agents=[AgentStatus(agent="claude"), AgentStatus(agent="kimi")]) assert report.any_stuck is False @@ -255,9 +253,7 @@ async def test_last_comment_time_with_comments(): mock_client = AsyncMock() mock_client.get = AsyncMock(return_value=mock_resp) - result = await _last_comment_time( - mock_client, "http://gitea/api/v1", {}, "owner/repo", 42 - ) + result = await _last_comment_time(mock_client, "http://gitea/api/v1", {}, "owner/repo", 42) assert result is not None assert result.year == 2024 assert result.month == 3 @@ -276,9 +272,7 @@ async def test_last_comment_time_uses_created_at_fallback(): mock_client = AsyncMock() mock_client.get = AsyncMock(return_value=mock_resp) - result = await _last_comment_time( - mock_client, "http://gitea/api/v1", {}, "owner/repo", 42 - ) + result = await _last_comment_time(mock_client, "http://gitea/api/v1", {}, "owner/repo", 42) assert result is not None @@ -293,9 +287,7 @@ async def test_last_comment_time_no_comments(): mock_client = AsyncMock() mock_client.get = AsyncMock(return_value=mock_resp) - result = await _last_comment_time( - mock_client, "http://gitea/api/v1", {}, "owner/repo", 99 - ) + result = await _last_comment_time(mock_client, "http://gitea/api/v1", {}, "owner/repo", 99) assert result is None @@ -309,9 +301,7 @@ async def test_last_comment_time_http_error(): mock_client = AsyncMock() mock_client.get = AsyncMock(return_value=mock_resp) - result = await _last_comment_time( - mock_client, "http://gitea/api/v1", {}, "owner/repo", 99 - ) + result = await _last_comment_time(mock_client, "http://gitea/api/v1", {}, "owner/repo", 99) assert result is None @@ -322,9 +312,7 @@ async def test_last_comment_time_exception(): mock_client = AsyncMock() mock_client.get = AsyncMock(side_effect=TimeoutError("timed out")) - result = await _last_comment_time( - mock_client, "http://gitea/api/v1", {}, "owner/repo", 7 - ) + result = await _last_comment_time(mock_client, "http://gitea/api/v1", {}, "owner/repo", 7) assert result is None @@ -376,8 +364,6 @@ async def test_check_agent_health_detects_stuck_issue(monkeypatch): mock_settings.gitea_url = "http://gitea" mock_settings.gitea_repo = "owner/repo" - import httpx - with patch("config.settings", mock_settings): status = await ah.check_agent_health("claude", stuck_threshold_minutes=120) diff --git a/tests/unit/test_vassal_dispatch.py b/tests/unit/test_vassal_dispatch.py index 522811f3..c098f3ee 100644 --- a/tests/unit/test_vassal_dispatch.py +++ b/tests/unit/test_vassal_dispatch.py @@ -337,8 +337,8 @@ async def test_perform_gitea_dispatch_updates_record(): mock_client.get.return_value = _mock_response(200, []) mock_client.post.side_effect = [ _mock_response(201, {"id": 1}), # create label - _mock_response(201), # apply label - _mock_response(201), # post comment + _mock_response(201), # apply label + _mock_response(201), # post comment ] with ( -- 2.43.0