Registry / testing / mypy-baseline

mypy-baseline

JSON →
library0.7.3pypypiunverified

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.

pip install mypy-baseline
INSTALL
IMPORT
SIG · MYPY-BASELINE
M
mypy-baseline
testingpythonv0.7.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

To get started, first ensure your mypy configuration (typically in `pyproject.toml`) includes `show_error_codes = true`. Then, generate an initial baseline to record all existing type errors. Subsequent runs can then filter mypy's output to only show new errors, helping to incrementally improve type coverage.

# 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.
mypy-baseline --version
Debug
Known issues
gotchamypy-baseline relies on mypy outputting error codes. Ensure your `mypy` configuration (e.g., in `pyproject.toml`) has `show_error_codes = true` for correct operation.
fix
Add `show_error_codes = true` under your `[tool.mypy]` section in `pyproject.toml` or equivalent mypy configuration.
affects: All versions
gotchaVersions 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.
fix
Upgrade to mypy-baseline 0.7.3 or newer to ensure correct baseline synchronization when using the `--sort-baseline` option.
affects: 0.7.0 - 0.7.2
gotchamypy-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.
fix
Upgrade to mypy-baseline 0.7.2 or newer to ensure `pyproject.toml` configurations (e.g., for `baseline_path`) are correctly respected.
affects: <0.7.2
gotchaThe 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.
fix
Run `mypy | mypy-baseline sync` to update your baseline file after resolving existing errors or making changes that affect the baseline.
affects: All versions
Errors
Common errors & fixes
mypy: command not found
The 'mypy' command is not installed or not available in the system's PATH.
fix
Install mypy using pip: 'python3 -m pip install mypy'.
mypy-baseline: command not found
The 'mypy-baseline' command is not installed or not available in the system's PATH.
fix
Install mypy-baseline using pip: 'python3 -m pip install mypy-baseline'.
mypy: error: unrecognized arguments: | mypy-baseline sync
Incorrect usage of the pipe operator '|' in the command; it should be used to pass the output of 'mypy' to 'mypy-baseline sync'.
fix
Ensure the command is correctly formatted: 'mypy | mypy-baseline sync'.
mypy: error: unrecognized arguments: --show-error-codes
The '--show-error-codes' option is not recognized, possibly due to an outdated version of mypy.
fix
Update mypy to the latest version using pip: 'python3 -m pip install --upgrade mypy'.
mypy-baseline: error: unrecognized arguments: filter
The 'filter' command is not recognized, possibly due to an outdated version of mypy-baseline.
fix
Update mypy-baseline to the latest version using pip: 'python3 -m pip install --upgrade mypy-baseline'.
Upgrade
Version history
0.7.3latest on PyPI · released May 30, 2025
Audit
Dependencies
mypyrequiredmypy-baseline processes the stdout of mypy, making mypy a required peer dependency for functionality. It is not listed as an install_requires.
Agent activity
9 hits · last 30 days
node
8
Resources
mypy-baseline — pip install mypy-baseline · libregistry