Skip to content

Add type annotations to all test files and enforce strict mypy #87

@Aureliolo

Description

@Aureliolo

Summary

Add return type annotations and full type hints to all test files, then remove the disallow_untyped_defs = false mypy override for tests.* so strict typing is enforced going forward.

Motivation

The pyproject.toml currently relaxes mypy for tests:

[[tool.mypy.overrides]]
module = "tests.*"
disallow_untyped_defs = false

This lets untyped test functions accumulate silently. As of now there are 219 mypy errors across 24 test files — a manageable amount. If we wait, this number will grow with every new test file, making the eventual cleanup much more painful.

Scope

  • Add -> None return annotations to all test functions and fixtures
  • Add parameter type annotations where missing (fixture args, parametrize helpers, etc.)
  • Fix any type-arg, arg-type, attr-defined, no-untyped-call errors that surface
  • Remove the disallow_untyped_defs = false override from pyproject.toml
  • Verify uv run mypy src/ tests/ passes with zero errors

Current error breakdown

Found 219 errors in 24 files (checked 67 source files)

Common error categories:

  • no-untyped-def: missing -> None on test functions
  • type-arg: missing generic type parameters (listlist[Any])
  • attr-defined: accessing attributes on BaseException instead of typed error classes
  • arg-type: dict invariance issues (dict[str, SubClass] vs dict[str, BaseClass])

Acceptance criteria

  • uv run mypy src/ tests/ passes with zero errors
  • disallow_untyped_defs = false override removed from pyproject.toml
  • All existing tests still pass
  • CI enforces typed tests going forward

Metadata

Metadata

Assignees

No one assigned

    Labels

    prio:highImportant, should be prioritizedprio:mediumShould do, but not blockingscope:medium1-3 days of workspec:architectureDESIGN_SPEC Section 15 - Technical Architecturespec:providersDESIGN_SPEC Section 9 - Model Provider Layertype:infraCI/CD, tooling, project setuptype:refactorCode restructuring, cleanup

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions