Skip to content

Add comprehensive type annotations across the codebase#114

Open
lucasfeliciano wants to merge 5 commits intoPauperformance:masterfrom
lucasfeliciano:add-type-annotations
Open

Add comprehensive type annotations across the codebase#114
lucasfeliciano wants to merge 5 commits intoPauperformance:masterfrom
lucasfeliciano:add-type-annotations

Conversation

@lucasfeliciano
Copy link
Collaborator

Summary

  • Add Python type annotations to all 96 .py files across the entire codebase (foundation, services, CLI, tasks, and tests)
  • Enable mypy strict mode with ignore_missing_imports = True in tox.ini — passes clean with 0 errors across 123 source files
  • Fix typing-related bugs discovered during annotation (e.g., BeautifulSoup.findAllfind_all, variable type shadowing in util/path.py)

Details

Annotations were added in a bottom-up layered approach:

  1. Foundation layer — entities, constants, utils, root files (37 files)
  2. Service layer — all service subdirectories (33 files)
  3. CLI and task layer (12 files)
  4. Test files (12 files)
  5. mypy strict fixes — resolved all strict-mode errors and configured ignore_missing_imports for untyped third-party libraries (36 files)

Key patterns used:

  • Modern Python 3.11+ syntax: list[str], dict[str, int], X | None
  • TypeVar for class decorator typing (auto_repr, auto_str)
  • Targeted # type: ignore[error-code] for genuinely unfixable issues (untyped libraries, method assignment in decorators)

Test plan

  • All 16 tests pass (2 skipped — secrets-related)
  • mypy strict mode: Success: no issues found in 123 source files
  • black and isort formatting verified

Annotate all function signatures, __init__ params, and return types.
Modernize typing: replace Optional[X] with X | None, List with list, etc.
Remove redundant self.x: type = x where param type suffices.
Annotate all function signatures across service/mtg, service/academy,
service/arena, service/nexus, and service/pauperformance.
Modernize typing: replace Optional/List/Dict/Tuple/DefaultDict with
modern equivalents (X | None, list, dict, tuple, defaultdict).
Annotate all function signatures in cli/builder, cli/group, cli/main,
and task modules. Use modern typing syntax throughout.
Annotate all test functions, fixtures, and helpers with parameter
and return types. Use modern typing syntax throughout.
- Fix type annotations to satisfy mypy strict mode (148 → 0 errors)
- Widen credential param types to str | None to match defaults
- Add type: ignore comments for unfixable issues (untyped libs, etc.)
- Fix unused type: ignore comments flagged by warn_unused_ignores
- Add ignore_missing_imports and warn_unused_ignores to mypy config
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.

1 participant