From 4d75ce6d484704871a9613a096ce69cb5f02ff2f Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Mon, 2 Nov 2026 10:04:36 +0100 Subject: [PATCH] focus_project: type-clean tests Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WzxdWXdzckyBH7fEbPywpr --- .../focus_project/tests/test_ledger_harvest.py | 10 +++++++--- .../focus_project/tests/test_leetcode_source.py | 2 +- focus_project/focus_project/tests/test_sources.py | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/focus_project/focus_project/tests/test_ledger_harvest.py b/focus_project/focus_project/tests/test_ledger_harvest.py index ad52c1f..a826b0d 100644 --- a/focus_project/focus_project/tests/test_ledger_harvest.py +++ b/focus_project/focus_project/tests/test_ledger_harvest.py @@ -7,6 +7,7 @@ from datetime import date, timedelta import json import logging from pathlib import Path # noqa: TC003 +from typing import Any import earned_time import pytest @@ -23,8 +24,11 @@ def _key(tmp_path: Path) -> None: (tmp_path / "hmac.key").write_bytes(KEY) -def rows() -> list[dict]: - return json.loads(ledger.ledger_path().read_text())["entries"] +def rows() -> list[dict[str, Any]]: + entries: list[dict[str, Any]] = json.loads(ledger.ledger_path().read_text())[ + "entries" + ] + return entries def beats(*times: float) -> None: @@ -146,7 +150,7 @@ def test_forged_and_malformed_rows_do_not_count() -> None: "detail": {**good["detail"], "minutes": 50}, } other_key = ledger.build_row("hr", D1, 9, 9, b"x" * 32, now=at(9)) - junk: list = [ + junk: list[Any] = [ "str", {"kind": "charge"}, {**good, "detail": "no"}, diff --git a/focus_project/focus_project/tests/test_leetcode_source.py b/focus_project/focus_project/tests/test_leetcode_source.py index 63014a9..8e6f644 100644 --- a/focus_project/focus_project/tests/test_leetcode_source.py +++ b/focus_project/focus_project/tests/test_leetcode_source.py @@ -19,7 +19,7 @@ from focus_project.tests.test_minutes import D1, at, project KEY = b"k" * 32 -def ac_row(ts: float, eid: str = "ac:1", key: bytes = KEY) -> dict: +def ac_row(ts: float, eid: str = "ac:1", key: bytes = KEY) -> dict[str, Any]: row: dict[str, Any] = { "entry_id": eid, "kind": "credit", diff --git a/focus_project/focus_project/tests/test_sources.py b/focus_project/focus_project/tests/test_sources.py index a4e8fb9..e6caced 100644 --- a/focus_project/focus_project/tests/test_sources.py +++ b/focus_project/focus_project/tests/test_sources.py @@ -100,7 +100,7 @@ def test_broken_adapter_import_contributes_zero( def broken(name: str) -> None: raise ImportError(name) - monkeypatch.setattr(sources.importlib, "import_module", broken) + monkeypatch.setattr("focus_project.sources.importlib.import_module", broken) with caplog.at_level(logging.ERROR): result = sources.collect_by_source(DAY, PROJECT) assert all(spans == [] for spans in result.values())