chore(mypy): type services/runtime/misc (src/ 42 -> 27)#1280
Open
axisrow wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.Changes (typing-only, no runtime behavior change)
regex/regex.*to theignore_missing_importsmodule list (third-party, ships no stubs) — clears theimport-untypedinnotification_matcher. Same pattern as the existingsklearn.*/yamlentries.TYPE_CHECKING-importnumpy as npandNearestNeighbors, annotate the lazy_matrix: np.ndarray | None/_index: NearestNeighbors | Nonefields (the imports stay runtime-lazy).all_activetoactive_pipelinesin the pipeline branch — the previous reuse of the same name (typedlist[SearchQuery]from the search-query branch above) caused a cross-branch assignment error.bot_payload: dict[str, Any]— it was inferred as bool-only from the initial{"configured": False}then widened with str/int/None values.str | dict[str, Any]andassert isinstance(data, dict)afterjson.loadsso the.get("nodes")/.get("edges")calls type-check (json.loads returnsAny).# type: ignore[call-arg]onDatabaseConfig()— the pydantic mypy plugin mis-reports theField(gt=0)/Field(ge=0)defaults as required (the defaults are valid and present).connected_phones_from_pool,_pool_reports_connections, etc.) are intentionally duck-typed overobject | Nonewithgetattr+ try/except. Replaced the few direct.clients/.connected_phonesattribute accesses (which mypy rejects onobject) withgetattr(...)and onecast(Any, ...)where the attribute is guarded bycallable(type(...).attr).Verification
ruff check src/ tests/ conftest.py— cleanpython -m mypy src/— 27 errors (was 42), untouched files unchanged; all 7 PR3 files at 0pytest tests/test_notification_matcher.py tests/test_agent_tools_registry.py tests/test_pipeline_graph.py tests/test_jobs_read_model.py— 143 passedpytest 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