Skip to content

chore(mypy): type services/runtime/misc (src/ 42 -> 27)#1280

Open
axisrow wants to merge 1 commit into
mainfrom
ao/tg_content_factory_5863f66be3-60/mypy-services-misc
Open

chore(mypy): type services/runtime/misc (src/ 42 -> 27)#1280
axisrow wants to merge 1 commit into
mainfrom
ao/tg_content_factory_5863f66be3-60/mypy-services-misc

Conversation

@axisrow

@axisrow axisrow commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Part of #1133 (mypy debt reduction axis). Independent sibling of #1275 (telegram utils) and #1277 (database) — disjoint files.

mypy delta

python -m mypy src/ on this branch: 42 errors -> 27 errors (−15). No new errors in untouched files (verified against per-file baseline). The remaining 27 are the PR1 (#1275) and PR2 (#1277) files, which this branch does not touch.

File Errors before After
src/agent/tools/_registry.py 3 0
src/config.py 2 0
src/models.py 2 0
src/search/numpy_semantic.py 2 0
src/scheduler/service.py 2 0
src/runtime/worker.py 3 0
src/services/notification_matcher.py 1 0

Changes (typing-only, no runtime behavior change)

  • pyproject mypy overrides: add regex / regex.* to the ignore_missing_imports module list (third-party, ships no stubs) — clears the import-untyped in notification_matcher. Same pattern as the existing sklearn.* / yaml entries.
  • numpy_semantic: TYPE_CHECKING-import numpy as np and NearestNeighbors, annotate the lazy _matrix: np.ndarray | None / _index: NearestNeighbors | None fields (the imports stay runtime-lazy).
  • scheduler/service: rename the loop-bound all_active to active_pipelines in the pipeline branch — the previous reuse of the same name (typed list[SearchQuery] from the search-query branch above) caused a cross-branch assignment error.
  • runtime/worker: annotate bot_payload: dict[str, Any] — it was inferred as bool-only from the initial {"configured": False} then widened with str/int/None values.
  • models.PipelineGraph.from_json: narrow the param to str | dict[str, Any] and assert isinstance(data, dict) after json.loads so the .get("nodes") / .get("edges") calls type-check (json.loads returns Any).
  • config: targeted # type: ignore[call-arg] on DatabaseConfig() — the pydantic mypy plugin mis-reports the Field(gt=0) / Field(ge=0) defaults as required (the defaults are valid and present).
  • agent/tools/_registry: the three pool helper functions (connected_phones_from_pool, _pool_reports_connections, etc.) are intentionally duck-typed over object | None with getattr + try/except. Replaced the few direct .clients / .connected_phones attribute accesses (which mypy rejects on object) with getattr(...) and one cast(Any, ...) where the attribute is guarded by callable(type(...).attr).

Verification

  • ruff check src/ tests/ conftest.py — clean
  • python -m mypy src/ — 27 errors (was 42), untouched files unchanged; all 7 PR3 files at 0
  • pytest tests/test_notification_matcher.py tests/test_agent_tools_registry.py tests/test_pipeline_graph.py tests/test_jobs_read_model.py143 passed
  • pytest tests/test_cli_dialogs_notifications_scheduler.py -k "scheduler or potential_job or job"46 passed

🤖 Generated with Claude Code

https://claude.ai/code/session_01G3ExCZyXkbUpTkRRrQrFA2

Part of #1133. Typing-only changes, no runtime behavior change:

- pyproject mypy overrides: add `regex` / `regex.*` (third-party, no stubs)
  -> clears notification_matcher import-untyped
- numpy_semantic: TYPE_CHECKING-import np / NearestNeighbors and annotate
  `_matrix` / `_index` fields (they are lazy-imported at runtime)
- scheduler/service: rename loop-bound `all_active` to `active_pipelines`
  in the pipeline branch so it is not re-typed from list[SearchQuery]
- runtime/worker: annotate `bot_payload` as dict[str, Any] (was inferred
  bool-only from the initial {"configured": False})
- models.PipelineGraph.from_json: narrow param to str | dict[str, Any]
  and assert after json.loads so the .get() calls type-check
- config: targeted type: ignore[call-arg] on DatabaseConfig() — pydantic
  Field(gt=0) defaults are mis-seen as required by the mypy plugin
- agent/tools/_registry: replace direct attribute access on duck-typed
  `object | None` client_pool with getattr/cast in the three pool helpers
  (clients / connected_phones / _pool_reports_connections)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3ExCZyXkbUpTkRRrQrFA2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant