Skip to content

Add comprehensive type annotations and mypy infrastructure#1285

Open
brianegge wants to merge 5 commits intomorganstanley:mainfrom
brianegge:add-type-annotations
Open

Add comprehensive type annotations and mypy infrastructure#1285
brianegge wants to merge 5 commits intomorganstanley:mainfrom
brianegge:add-type-annotations

Conversation

@brianegge
Copy link

@brianegge brianegge commented Mar 7, 2026

Summary

  • Add type annotations across 109 files (218 checked modules) with zero mypy errors
  • Add mypy configuration in pyproject.toml with per-module strict overrides for 47 modules
  • Add py.typed marker for PEP 561 compliance and types-paramiko/types-requests stub packages
  • Add doit mypy task for running type checks
  • Type the emphasized decorator with TypeVar to preserve decorated property types
  • Use assert/isinstance narrowing instead of blanket # type: ignore suppressions where possible
  • Apply ruff formatting fixes and resolve additional mypy errors from CI

All 446 remaining # type: ignore comments use specific error codes. The majority are structural to the framework's Config __getattr__ pattern (attr-defined, no-any-return) and mypy's prop-decorator limitation.

Test plan

  • mypy testplan/ --config-file pyproject.toml passes with zero errors (218 source files)
  • Ruff formatting passes
  • Existing test suite passes (no runtime behavior changes)

🤖 Generated with Claude Code

Add type annotations across the entire testplan codebase (109 files,
218 checked modules) with zero mypy errors.

Infrastructure:
- Add mypy configuration in pyproject.toml with per-module strict overrides
- Add py.typed marker for PEP 561 compliance
- Add types-paramiko and types-requests stub packages
- Add doit task for running mypy

Key patterns:
- TypeVar-typed `emphasized` decorator to preserve property types
- Targeted `# type: ignore[error-code]` for framework meta-programming
- isinstance/assert narrowing to replace union-attr suppressions
- Python 3.9 compatible (Optional[X] not X | None)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@brianegge brianegge requested a review from a team as a code owner March 7, 2026 11:57
claude and others added 4 commits March 7, 2026 12:38
- Fix 17 mypy errors for compatibility with mypy 1.19:
  - Add type: ignore[no-any-return] for functions returning Any
  - Add type: ignore[import-untyped] for paramiko/requests imports
  - Remove unused type: ignore comments
  - Fix displaced type: ignore comments after ruff reformatting
- Apply ruff formatting across all files
- Update constraints.txt via uv export

https://claude.ai/code/session_018SqKHFDkaRQHVnZUKukBSe
- Restore pylint disable comment on opentelemetry import
- Revert vendor/tempita formatting (vendored code should not be modified)
- Remove stale import-untyped ignores now resolved by type stub packages
- Remove stale no-any-return ignores resolved by stubs (orjson, click)
- Add type: ignore for marshmallow schema field assignment mismatches
- Fix type: ignore placement on correct lines

Co-Authored-By: Claude Opus 4.6 <[email protected]>
The updated constraints bumped pylint 4.0.4 -> 4.0.5 which treats
pre-existing vendor import errors as fatal. Revert to main's
constraints to fix CI lint failures.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
ExceptionGroup is properly typed when exceptiongroup backport is
installed (CI Python 3.10), making the no-any-return ignore unused.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.

2 participants