Skip to content

[Python SDK] Adopt mypy in CI (module-by-module ratchet) #971

Description

@AbirAbbas

Split out of #620, where the reporter asked for "mypy and ruff for strict checks of async / blocking code". The ruff half shipped in #812 (ASYNC ruleset, enforced in CI on 3.10/3.11/3.12). The mypy half was never adopted: sdk/python/mypy.ini exists but nothing in .github/workflows/sdk-python.yml runs it, and mypy --config-file mypy.ini agentfield/ currently reports ~194 errors across ~28 files.

What "done" looks like

  • A mypy step in sdk/python CI that is required to pass.
  • A per-module allowlist ([mypy-agentfield.<module>] with ignore_errors = True) for modules that are not yet clean, so the gate can be turned on immediately and the allowlist shrunk module by module.
  • No # type: ignore sprinkling to get to green — fix the type or allowlist the module.

Suggested order

  1. Land the CI step with everything allowlisted (zero behaviour change, proves the wiring).
  2. Clean the async-heavy modules first, since that is the reporter's concern: run_async.py, lock_utils.py, async_lifecycle.py, result_cache.py, async_execution_manager.py, http_connection_manager.py, memory_events.py, logger.py.
  3. Then client.py and agent.py, which carry most of the remaining count.

Validation contract

  • CI fails if a non-allowlisted module gains a new mypy error.
  • Removing a module from the allowlist while it still has errors fails CI.
  • pip install .[dev] provides the pinned mypy version used in CI.

Refs #620.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededsdk:pythonPython SDK related

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions