[loop-cycle] fix: remove unused imports and fix formatting (lint) (#1209)
Some checks failed
Tests / lint (push) Has been cancelled
Tests / test (push) Has been cancelled

This commit was merged in pull request #1209.
This commit is contained in:
2026-03-23 22:30:03 +00:00
parent 46edac3e76
commit 25157a71a8
6 changed files with 25 additions and 42 deletions

View File

@@ -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,
)

View File

@@ -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):

View File

@@ -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

View File

@@ -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")

View File

@@ -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)

View File

@@ -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 (