[AAASM-3017] 🚨 (python-sdk): Clear pre-existing mypy errors#130
Conversation
The agent_assembly/proto/*_pb2*.py / .pyi modules are emitted by scripts/gen_proto.py and committed verbatim; a CI drift check regenerates them and asserts no diff. Add a [mypy-agent_assembly.proto.*] ignore_errors override so we do not hand-annotate code we do not own. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The mirrors-mypy hook ran in an isolated venv lacking the SDK's runtime and framework deps, so pydantic/httpx/framework base classes resolved to Any, and passing raw file paths tripped a "Duplicate module" error on the generated proto .py/.pyi pairs. Switch to a local hook (`uv run mypy`, pass_filenames: false) so the hook resolves real deps and uses mypy.ini `packages =` discovery — making it identical to the configured `mypy` invocation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add type args to bare `dict` (return types, body/metadata params) and bind httpx `.json()` results to typed locals to clear no-any-return. Annotations only — no runtime change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mypy rejects `-> bool` for an __exit__ that always returns False (exit-return). Narrow the annotation to Literal[False]; the returned value is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The configured mypy run passes --ignore-missing-imports, so the scoped ignore on the native `_core` import was flagged unused. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Use `import X as X` so mypy treats the lazily-exported public symbols as explicitly exported, clearing the "does not explicitly export attribute" errors raised when tests import them from `agent_assembly`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Tests reach into `<patch>.importlib` to monkeypatch import_module; under package discovery mypy treats the plain `import importlib` as non-exported. Use the `import importlib as importlib` re-export idiom so the attribute access type-checks. No runtime change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Annotate `_patched_client` as AbstractContextManager[Any] and the response payload dict so the `with` usage and dict args type-check. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a `_Subscriber` tuple alias for the fixture yield, `-> None` returns, and a scoped arg-type ignore on the proto enum-int constructor call. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add return/param annotations and dict type args to the spawn-context tests; remove a now-unused parametrize ignore in test_gateway_resolver. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add `-> None` returns and fixture param types; scope arg-type ignores on the placeholder client passed to `_start_network_layer`, and attr-defined ignores on the fake `_core` ModuleType used by the export test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The round-trip decodes the out-of-enum "unknown" wire fallback, which is not in the static Literal type for `kind`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The base tests deliberately instantiate an abstract adapter (to assert TypeError) and call `record_event` on the empty GovernanceInterceptor Protocol via a fake that implements it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Type replacement-function signatures, dict params, and node_map; narrow SpawnContext|None via the file's existing `assert ... is not None` idiom; and scope func-returns-value ignores on the deliberate `append() or X` lambdas. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Annotate replacement-function signatures and scope method-assign/assignment ignores on the fake Agent/Tool method reassignments. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Annotate replacement-function signatures, scope method-assign ignores on the fake Task/Crew swaps, and a type-var ignore on sorting str|None test data. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Annotate replacement-function signatures and dict params; scope method-assign/assignment/arg-type ignores on the fake Runner classmethod swaps and an index ignore on the dict-returning approval fallback; drop a stale attr-defined ignore in the mcp patch test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tests Add return/param annotations and a typed native_core fixture; scope method-assign ignores on fake method swaps and misc/valid-type ignores on the runtime-imported crewai BaseTool subclasses. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
🤖 Claude Code — PR reviewTicket: AAASM-3017 — Clear the pre-existing mypy debt on CI — 🟡 green except two coverage gates (ignored per policy)All functional checks pass: Two reds, both pure coverage acceptance gates (the SonarQube/coverage class we set aside):
Why this is expected and not a real gap: this is a typing-only change (annotations, Scope vs. acceptance criteria — ✅ complete
20 granular commits; lane clean ( Notes for reviewer (conscious-look items, non-blocking)
ReadinessReady to merge pending one Pioneer-team approval. Type-clean, behaviour-preserving (tests identical to master), and it un-breaks the local pre-commit mypy hook for everyone. The two reds are coverage-only and expected for a typing PR. Recorded as a review note; no formal approval submitted. |


Description
Clears the pre-existing mypy errors carried on
masterso the localpre-commit
mypyhook passes and stops masking new regressions. Theconfigured mypy run goes from 326 errors (45 files) — or 319 under the
hook's
--ignore-missing-imports— down to 0.All changes are behaviour-preserving typing fixes only: added/repaired type
annotations (params, returns, dict/list type-args, context managers), explicit
import X as Xre-exports, and scoped# type: ignore[code]comments withshort reasons where a real fix is not feasible (mypy method-reassignment
limitation on monkeypatch-style fakes, generated-stub gaps, runtime-imported
framework base classes, deliberate abstract-instantiation tests). No control
flow, values, or public runtime signatures were changed.
Two small infra fixes make the gate actually meaningful and reproducible:
mypy.ini: skip the generatedagent_assembly.proto.*stubs (drift-checked,must not be hand-edited).
.pre-commit-config.yaml: run mypy viauv run mypywithpass_filenames: falseso the hook resolves the project's real deps(pydantic/httpx/frameworks) and uses
packages =discovery — making the hookbyte-for-byte identical to the configured
mypyinvocation (previously it ranin an isolated dep-less venv and crashed on the proto
.py/.pyiduplicate).Fix categories: ~real annotation fixes across 10 source files + ~24 test files;
scoped ignores limited to unavoidable mypy/test-mock limitations, each with a
reason comment.
Type of Change
Breaking Changes
Related Issues
Testing
Verification:
mypy --ignore-missing-imports: 0 errors (was 319/326).pre-commit run mypy --all-files: Passed.pytest test/: 443 passed, 9 skipped (unchanged from master).ruff check .: 199 (== master baseline; no regression — repo lints viablack/isort/autoflake, not ruff).
Checklist
🤖 Generated with Claude Code