Skip to main content

Integrate mypy with existing codebase.

Project description

mypy-baseline

A CLI tool for painless integration of mypy with an existing Python project. When you run it for the first time, it will remember all type errors that you already have in the project (generate "baseline"). All consequentive runs will ignore these errors and report only ones that you introduced after that.

Additionally, the tool will show you what progress you made since the last baseline, to encourage your team to resolve mypy errors:

example of the command output

Features:

  • Battle-tested.
  • Fast and simple.
  • Pure Python.
  • No mypy patching or dirty magic. The tool works exclusively with the stdout of mypy.
  • Nice stats with colors.
  • Can detect exactly what errors were introduced and what errors were resolved, even if they are in the same file.
  • Baseline is carefully crafted to avoid merge conflicts.
  • Baseline is human-readable, and diffs are informative. The reviewers of your PR will know exactly what errors you resolve and what errors you introduced.

Installation

python3 -m pip install mypy-baseline

Usage

First of all, you need to create the baseline (will be stored in mypy-baseline.txt by default):

mypy --show-codes | mypy-baseline sync

After that, you can pipe mypy output into mypy-baseline filter, and it will filter out all issues that are already in the baseline:

mypy --show-codes | mypy-baseline filter

If you introduce new errors, resolve them. If you resolve existing errors, run mypy-baseline sync again to re-generate baseline. In both cases, mypy-baseline will tell you what's wrong and what to do. Enjoy the ride!

Configuration

The tool has a number of CLI flags to configure the behavior of filter. The default value for each flag can be specified in pyproject.toml. There are all the configuration options and their defaults:

[tool.mypy-baseline]
# --baseline-path: the file where the baseline should be stored
baseline_path = "mypy-baseline.txt"
# --depth: cut path names longer than that many directories deep
depth = 40
# --allow-unsynced: do not fail for unsynced resolved errors
allow_unsynced = False
# --preserve-position: do not remove error position from the baseline
preserve_position = False
# --hide-stats: do not show stats and messages at the end
hide_stats = False
# --no-colors: do not use colors in stats
no_colors = False

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mypy_baseline-0.1.0.tar.gz (127.4 kB view details)

Uploaded Source

Built Distribution

mypy_baseline-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file mypy_baseline-0.1.0.tar.gz.

File metadata

  • Download URL: mypy_baseline-0.1.0.tar.gz
  • Upload date:
  • Size: 127.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for mypy_baseline-0.1.0.tar.gz
Algorithm Hash digest
SHA256 68293e8a0b8143d08a62cd47d7c1b1a37feabbd18062872ba2d52a64de4906e7
MD5 94eb499e773c22374409914fb6a64b31
BLAKE2b-256 55e70edc706cc70d688328346feedd983090229353e89097de9bacd904f0c5ba

See more details on using hashes here.

File details

Details for the file mypy_baseline-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mypy_baseline-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79c604d7fe3c82c225521cbb9d5579f482736abac6c5dcc5caab7eb967cdbdfd
MD5 de36d122a64b658e90d14b56ee88fea4
BLAKE2b-256 6ade9ccc1afc4f73abf39aaceb77923445a1d0194b9a781423ec8ecb0cb95af7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page