Skip to main content

Generate a JSON report from your mypy output

Project description

Mypy JSON Report

A JSON report of your mypy output that helps you push towards full type coverage of your project.

Quickstart

Install with pip.

pip install mypy-json-report

Pipe the output of mypy through the mypy-json-report CLI app. Store the output to a file, and commit it to your git repo.

mypy . --strict | mypy-json-report parse --output-file mypy-ratchet.json
git add mypy-ratchet.json
git commit -m "Add mypy errors ratchet file"

Now you have a snapshot of the mypy errors in your project. Compare against this file when making changes to your project to catch regressions and improvements.

Example output

If mypy was showing you errors like this:

example.py:8: error: Function is missing a return type annotation
example.py:8: note: Use "-> None" if function does not return a value
example.py:58: error: Call to untyped function "main" in typed context
example.py:69: error: Call to untyped function "main" in typed context
Found 3 errors in 1 file (checked 3 source files)

Then the report would look like this:

{
  "example.py": {
    "Call to untyped function \"main\" in typed context": 2,
    "Function is missing a return type annotation": 1
  }
}

Errors are grouped by file. To reduce churn, the line on which the errors occur is removed and repeated errors are counted.

Ratchet file

The --diff-old-report FILENAME flag serves two purposes.

  1. It prints new (and adjacent, and similar) errors to STDERR. This is useful for seeing what errors need to be fixed before committing.

  2. It will error when the ratchet file doesn't match the new report. This is helpful for catching uncommitted changes in CI.

Example usage

You could create a GitHub Action to catch regressions (or improvements).

---
name: Mypy check

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

  mypy:
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.10"

      - name: Install Python dependencies
        run: |
          pip install mypy mypy-json-report

      - name: Run mypy
        run: |
          mypy . --strict | mypy-json-report parse --diff-old-report mypy-ratchet.json --output-file mypy-ratchet.json

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_json_report-1.3.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mypy_json_report-1.3.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file mypy_json_report-1.3.0.tar.gz.

File metadata

  • Download URL: mypy_json_report-1.3.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mypy_json_report-1.3.0.tar.gz
Algorithm Hash digest
SHA256 ce0cb77e7123540f825ca3370f41a315af98224d406db2d0342214d304d5e9b6
MD5 1e5fcf3a8c4bed5efddff5c1c87b849c
BLAKE2b-256 f14c527df0fd567f44b2acd153a645cc259ad9cabc1c52526522cafdf4b70128

See more details on using hashes here.

Provenance

The following attestation bundles were made for mypy_json_report-1.3.0.tar.gz:

Publisher: release-to-pypi.yml on Memrise/mypy-json-report

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mypy_json_report-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mypy_json_report-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 846ba1d3bc3f4d20664c91e7747053b89b66b0311fc7b3a16339b698c2a23b55
MD5 acc9a38d654acef74e69d2e816b43f9a
BLAKE2b-256 84ea27988dcd49f9f264e12c98667adfe086b65752b9d70cd0d51a595c06e033

See more details on using hashes here.

Provenance

The following attestation bundles were made for mypy_json_report-1.3.0-py3-none-any.whl:

Publisher: release-to-pypi.yml on Memrise/mypy-json-report

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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