financeager icon indicating copy to clipboard operation
financeager copied to clipboard

Add comprehensive type annotations and mypy configuration with Python 3.10+ support

Open Copilot opened this issue 6 months ago • 3 comments

This PR implements comprehensive type annotations throughout the financeager codebase to improve code safety and developer experience. The implementation follows modern Python typing best practices and includes full mypy integration with proper CI/CD configuration.

Key Changes

Type Annotations

  • Complete coverage: Added type annotations to all 12 Python files in the financeager/ directory
  • Modern syntax: Used Python 3.10+ features (str | None instead of Optional[str], list[str] instead of List[str])
  • Clean mypy configuration: No library ignores needed - all dependencies (argcomplete, marshmallow, tinydb, dateutil) provide proper type stubs

Python Version Requirements

  • Dropped Python 3.9 support: Updated to require Python 3.10+ (requires-python = ">=3.10")
  • CI/CD updates: Removed Python 3.9 from GitHub Actions test matrix
  • Removed compatibility code: Eliminated Python 3.9 workarounds (e.g., EntryPoints.get() fallback)

MyPy Configuration

  • Clean setup: Configured mypy with gradual adoption approach in pyproject.toml
  • No ignores required: All external dependencies have proper type information
  • Strict checks: Enabled key safety features while allowing incremental improvement

CI/CD Integration

  • Pre-commit hooks: Added mypy to the pre-commit configuration with proper file handling
  • GitHub Actions: Integrated type checking through pre-commit hooks in CI workflow
  • Developer workflow: Type checking runs automatically before commits and in CI

Documentation

  • Migration guide: Added comprehensive typing migration section to README explaining progressive typing adoption

Technical Details

The implementation maintains 100% backward compatibility for Python 3.10+ while adding type safety. All pre-commit hooks (black, flake8, isort, mypy) pass successfully, and the mypy configuration requires no external library ignores since all dependencies provide proper type stubs.

Fixes #254.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot avatar Aug 04 '25 08:08 Copilot

couple of remarks, please work on these

@copilot work on my PR review comments

pylipp avatar Aug 05 '25 20:08 pylipp

Coverage Status

coverage: 98.73% (-0.4%) from 99.103% when pulling c68e8562d69279e4474cdd2a0e726560b140299a on copilot/fix-254 into 4dd42e171110afc9c89fe7403cb8ea808005d160 on master.

coveralls avatar Aug 05 '25 21:08 coveralls

I have some more remarks @copilot please work on them.

Also remove Python 3.9 from workflow in ci.yml

Removed Python 3.9 from the CI workflow matrix and project classifiers. Also removed the Python 3.9 compatibility code from cli.py since it's no longer needed, and added requires-python = ">=3.10" to properly declare the minimum version requirement. (300d76d)

Copilot avatar Aug 06 '25 07:08 Copilot