From 002ace5b3c1db29a9247f3b15a827820f2cb8f38 Mon Sep 17 00:00:00 2001 From: Timmy Time Date: Tue, 24 Mar 2026 09:39:12 +0000 Subject: [PATCH] [loop-cycle-7] fix: Configure mypy with explicit-package-bases for proper src/ layout (#1346) (#1359) --- pyproject.toml | 26 ++++++++++++++++++++++++++ src/dashboard/app.py | 4 ++-- src/timmy/memory/consolidation.py | 2 +- tests/scripts/test_llm_triage.py | 4 ++-- tests/spark/test_engine.py | 10 ++++++---- tests/timmy/test_system_tools.py | 1 - 6 files changed, 37 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ff149beb..95d415b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -167,3 +167,29 @@ directory = "htmlcov" [tool.coverage.xml] output = "coverage.xml" + +[tool.mypy] +python_version = "3.11" +mypy_path = "src" +explicit_package_bases = true +namespace_packages = true +check_untyped_defs = true +warn_unused_ignores = true +warn_redundant_casts = true +warn_unreachable = true +strict_optional = true + +[[tool.mypy.overrides]] +module = [ + "airllm.*", + "pymumble.*", + "pyttsx3.*", + "serpapi.*", + "discord.*", + "psutil.*", + "health_snapshot.*", + "swarm.*", + "lightning.*", + "mcp.*", +] +ignore_missing_imports = true diff --git a/src/dashboard/app.py b/src/dashboard/app.py index 885d6283..61dd99be 100644 --- a/src/dashboard/app.py +++ b/src/dashboard/app.py @@ -40,6 +40,7 @@ from dashboard.routes.experiments import router as experiments_router from dashboard.routes.grok import router as grok_router from dashboard.routes.health import router as health_router from dashboard.routes.hermes import router as hermes_router +from dashboard.routes.legal import router as legal_router from dashboard.routes.loop_qa import router as loop_qa_router from dashboard.routes.memory import router as memory_router from dashboard.routes.mobile import router as mobile_router @@ -49,8 +50,8 @@ from dashboard.routes.monitoring import router as monitoring_router from dashboard.routes.nexus import router as nexus_router from dashboard.routes.quests import router as quests_router from dashboard.routes.scorecards import router as scorecards_router -from dashboard.routes.legal import router as legal_router from dashboard.routes.self_correction import router as self_correction_router +from dashboard.routes.seo import router as seo_router from dashboard.routes.sovereignty_metrics import router as sovereignty_metrics_router from dashboard.routes.sovereignty_ws import router as sovereignty_ws_router from dashboard.routes.spark import router as spark_router @@ -63,7 +64,6 @@ from dashboard.routes.tools import router as tools_router from dashboard.routes.tower import router as tower_router from dashboard.routes.voice import router as voice_router from dashboard.routes.work_orders import router as work_orders_router -from dashboard.routes.seo import router as seo_router from dashboard.routes.world import matrix_router from dashboard.routes.world import router as world_router from timmy.workshop_state import PRESENCE_FILE diff --git a/src/timmy/memory/consolidation.py b/src/timmy/memory/consolidation.py index 4641c60b..6564e528 100644 --- a/src/timmy/memory/consolidation.py +++ b/src/timmy/memory/consolidation.py @@ -92,7 +92,7 @@ class HotMemory: now = datetime.now(UTC).strftime("%Y-%m-%d %H:%M UTC") lines = [ "# Timmy Hot Memory\n", - f"> Working RAM — always loaded, ~300 lines max, pruned monthly", + "> Working RAM — always loaded, ~300 lines max, pruned monthly", f"> Last updated: {now}\n", ] diff --git a/tests/scripts/test_llm_triage.py b/tests/scripts/test_llm_triage.py index 37e57f53..a6e5514a 100644 --- a/tests/scripts/test_llm_triage.py +++ b/tests/scripts/test_llm_triage.py @@ -1,7 +1,6 @@ -from unittest.mock import MagicMock, patch +from unittest.mock import patch import pytest - from scripts.llm_triage import ( get_context, get_prompt, @@ -9,6 +8,7 @@ from scripts.llm_triage import ( run_triage, ) + # ── Mocks ────────────────────────────────────────────────────────────────── @pytest.fixture def mock_files(tmp_path): diff --git a/tests/spark/test_engine.py b/tests/spark/test_engine.py index af8c6bd5..b7764946 100644 --- a/tests/spark/test_engine.py +++ b/tests/spark/test_engine.py @@ -10,8 +10,9 @@ Covers the public API and internal helpers not exercised in other test files: - Disabled-engine guard for every mutating method """ +from unittest.mock import MagicMock, patch + import pytest -from unittest.mock import patch, MagicMock @pytest.fixture(autouse=True) @@ -128,11 +129,10 @@ class TestGetSparkEngineSingleton: mock_settings = MagicMock() mock_settings.spark_enabled = False with patch("spark.engine.settings", mock_settings, create=True): - from spark.engine import get_spark_engine, reset_spark_engine + from spark.engine import reset_spark_engine reset_spark_engine() # Patch at import time by mocking the config module in engine import spark.engine as engine_module - original_func = engine_module.get_spark_engine def patched_get(): global _spark_engine @@ -181,8 +181,8 @@ class TestModuleLevelGetattr: class TestOnTaskPostedWithoutCandidates: def test_no_eidos_prediction_when_no_candidates(self): """When candidate_agents is empty, no EIDOS prediction should be stored.""" - from spark.engine import SparkEngine from spark.eidos import get_predictions + from spark.engine import SparkEngine engine = SparkEngine(enabled=True) eid = engine.on_task_posted("t1", "Background task", candidate_agents=[]) @@ -208,6 +208,7 @@ class TestOnTaskCompletedWithBid: def test_winning_bid_stored_in_data(self): """winning_bid is serialised into the event data field.""" import json + from spark.engine import SparkEngine from spark.memory import get_events @@ -220,6 +221,7 @@ class TestOnTaskCompletedWithBid: def test_without_winning_bid_is_none(self): import json + from spark.engine import SparkEngine from spark.memory import get_events diff --git a/tests/timmy/test_system_tools.py b/tests/timmy/test_system_tools.py index b8293546..4760e9c8 100644 --- a/tests/timmy/test_system_tools.py +++ b/tests/timmy/test_system_tools.py @@ -10,7 +10,6 @@ from __future__ import annotations import ast import math import subprocess -from pathlib import Path from unittest.mock import MagicMock, patch import pytest