mypy-baseline
mypy-baseline is a friendly CLI tool designed to integrate the `mypy` static type checker into existing Python projects. It works by creating and managing a 'baseline' file of current type errors, allowing developers to focus on new errors introduced while gradually addressing the existing technical debt. Currently at version 0.7.3, it maintains an active development and release cadence.
Warnings
- gotcha mypy-baseline relies on mypy outputting error codes. Ensure your `mypy` configuration (e.g., in `pyproject.toml`) has `show_error_codes = true` for correct operation.
- gotcha Versions 0.7.0 to 0.7.2 had a bug where the `--sort-baseline` option could cause incorrect stable sync behavior. This was fixed in 0.7.3.
- gotcha mypy-baseline versions prior to 0.7.2 had a bug where configuration in `pyproject.toml` might be ignored, leading to unexpected behavior or reliance on CLI flags.
- gotcha The tool will intentionally fail if there are resolved but unsynced errors in your codebase. This is by design to encourage keeping the `mypy-baseline.txt` file up-to-date.
Install
-
pip install mypy-baseline
Quickstart
# 1. Ensure mypy is configured to show error codes (e.g., in pyproject.toml): # [tool.mypy] # show_error_codes = true # 2. Generate the initial baseline (mypy-baseline.txt by default) # This will capture all current mypy errors. mypy | mypy-baseline sync # 3. Filter mypy output, reporting only new errors not in the baseline mypy | mypy-baseline filter # If you resolve existing errors or introduce new ones, run 'mypy | mypy-baseline sync' # again to update the baseline.