mypy-json-report


Namemypy-json-report JSON
Version 1.2.0 PyPI version JSON
download
home_pagehttps://github.com/memrise/mypy-json-report
SummaryGenerate a JSON report from your mypy output
upload_time2024-04-09 07:37:36
maintainerNone
docs_urlNone
authorCharlie Denton
requires_python<4.0,>=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```json
{
  "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.

1. 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).

```yaml
---
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
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/memrise/mypy-json-report",
    "name": "mypy-json-report",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Charlie Denton",
    "author_email": "charlie@meshy.co.uk",
    "download_url": "https://files.pythonhosted.org/packages/31/75/dbe801c0119d38b0f8b2c9ac5beebc8d553ed92bb1edf73bbf3bef21fcf4/mypy_json_report-1.2.0.tar.gz",
    "platform": null,
    "description": "# Mypy JSON Report\n\nA JSON report of your mypy output\nthat helps you push towards full type coverage of your project.\n\n## Quickstart\n\nInstall with pip.\n```\npip install mypy-json-report\n```\n\nPipe the output of mypy through the `mypy-json-report` CLI app.\nStore the output to a file, and commit it to your git repo.\n\n```\nmypy . --strict | mypy-json-report parse --output-file mypy-ratchet.json\ngit add mypy-ratchet.json\ngit commit -m \"Add mypy errors ratchet file\"\n```\n\nNow you have a snapshot of the mypy errors in your project.\nCompare against this file when making changes to your project to catch regressions and improvements.\n\n## Example output\n\nIf mypy was showing you errors like this:\n\n```\nexample.py:8: error: Function is missing a return type annotation\nexample.py:8: note: Use \"-> None\" if function does not return a value\nexample.py:58: error: Call to untyped function \"main\" in typed context\nexample.py:69: error: Call to untyped function \"main\" in typed context\nFound 3 errors in 1 file (checked 3 source files)\n```\n\nThen the report would look like this:\n\n```json\n{\n  \"example.py\": {\n    \"Call to untyped function \\\"main\\\" in typed context\": 2,\n    \"Function is missing a return type annotation\": 1\n  }\n}\n```\n\nErrors are grouped by file.\nTo reduce churn,\nthe line on which the errors occur is removed\nand repeated errors are counted.\n\n\n## Ratchet file\n\nThe `--diff-old-report FILENAME` flag serves two purposes.\n\n1. It prints new (and adjacent, and similar) errors to STDERR.\n   This is useful for seeing what errors need to be fixed before committing.\n\n1. It will error when the ratchet file doesn't match the new report.\n   This is helpful for catching uncommitted changes in CI.\n\n## Example usage\n\nYou could create a GitHub Action to catch regressions (or improvements).\n\n```yaml\n---\nname: Mypy check\n\non: [push]\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n  mypy:\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v2\n\n      - name: Set up Python\n        uses: actions/setup-python@v2\n        with:\n          python-version: \"3.10\"\n\n      - name: Install Python dependencies\n        run: |\n          pip install mypy mypy-json-report\n\n      - name: Run mypy\n        run: |\n          mypy . --strict | mypy-json-report parse --diff-old-report mypy-ratchet.json --output-file mypy-ratchet.json\n```\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Generate a JSON report from your mypy output",
    "version": "1.2.0",
    "project_urls": {
        "Homepage": "https://github.com/memrise/mypy-json-report",
        "Repository": "https://github.com/memrise/mypy-json-report"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3b0a9b08df3e632ae190bf7812782dba7067148404bc4f3ce22e9ce2f0aef762",
                "md5": "90b2e6e36483c1af1abbfac1149ae19b",
                "sha256": "44977105067354b9d79dd07e30677daeb7641ac87a58048aa2f0d2b9172f1be4"
            },
            "downloads": -1,
            "filename": "mypy_json_report-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "90b2e6e36483c1af1abbfac1149ae19b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 13222,
            "upload_time": "2024-04-09T07:37:34",
            "upload_time_iso_8601": "2024-04-09T07:37:34.524045Z",
            "url": "https://files.pythonhosted.org/packages/3b/0a/9b08df3e632ae190bf7812782dba7067148404bc4f3ce22e9ce2f0aef762/mypy_json_report-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3175dbe801c0119d38b0f8b2c9ac5beebc8d553ed92bb1edf73bbf3bef21fcf4",
                "md5": "e7bca3a676effb55338cc0c6de33a076",
                "sha256": "2e1486617caf746fde1818d58cdf060968d1db5173a50456d2e76803a0c2bd17"
            },
            "downloads": -1,
            "filename": "mypy_json_report-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e7bca3a676effb55338cc0c6de33a076",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 11168,
            "upload_time": "2024-04-09T07:37:36",
            "upload_time_iso_8601": "2024-04-09T07:37:36.056875Z",
            "url": "https://files.pythonhosted.org/packages/31/75/dbe801c0119d38b0f8b2c9ac5beebc8d553ed92bb1edf73bbf3bef21fcf4/mypy_json_report-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-09 07:37:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "memrise",
    "github_project": "mypy-json-report",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "mypy-json-report"
}
        
Elapsed time: 0.70706s