Skip to main content

mypy-code-climate

PyPI - Python Version PyPI Downloads PyPI - License Code style: black Ruff

Standalone tool to convert Mypy output to Code Climate format. It does not require the Code Climate CLI and is dependency-free: great for CI/CD. Keeps sane exit codes for your CI. Additionally, can be used as a Python library.

Why Code Climate

The Code Climate format is supported by Gitlab CI, so you can generate a Code Quality report from mypy output, and have it tracked and displayed in your Gitlab UI.

Usage

mypy-to-codeclimate <mypy_output_file> <code_climate_output_file>

Example:

mypy-to-codeclimate mypy-output.txt mypy-codequality.json

You can replace the filename by - to read from stdin, write to stdout, or both.

mypy <command_args> | mypy-to-codeclimate - mypy-codequality.json

Return codes

  • 0: Success, no mypy errors
  • 1: Mypy errors, codeclimate report generated
  • 2: Mypy crash (unexpected error) or mypy-to-codeclimate error (invalid arguments, invalid input file, etc.)

Options

  • --version: Print version and exit
  • --help: Print help and exit

Installation

pip install mypy-to-codeclimate

The package is distributed on Pypi, so you can install it with pipx, PDM, Poetry or any other Python package manager.

Supported versions

Mypy versions

Tested against Mypy 1.6.1. It should work with any version of mypy that outputs the same format.

Please open an issue if you find a version of mypy that is not supported.

Example usage in Gitlab CI

Example of a job that runs mypy and generates a codeclimate report, on a Linux runner.

Dependency management is left as an exercise for the reader.

See Gitlab CI code-quality artifacts reference

lint_python_mypy:
  script:
    - mypy --version
    # Disable exit on error and pipefail:
    # mypy-code-climate will return a non-zero exit code if there are errors but we want to continue the job to generate the report
    - set +eo pipefail
    - mypy <command_args> | tee mypy-output.txt"
    # Enable exit on error again
    - set -xeo
    - mypy-to-codeclimate mypy-output.txt mypy-codequality.json
  artifacts:
    when: always
    paths:
      - mypy-codequality.json
    reports:
      codequality: mypy-codequality.json

License

MIT, see LICENSE file.

Acknowledgements

Inspired by codeclimate-mypy by Scott Larkin (@larkinscott).

Metadata

Release files for mypy-to-codeclimate 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mypy-to-codeclimate 0.0.3
File Size Uploaded
mypy_to_codeclimate-0.0.3.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mypy-to-codeclimate 0.0.3
File Interpreter ABI Platform
mypy_to_codeclimate-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 14.3 kB

Release files / mypy_to_codeclimate-0.0.3.tar.gz

Download URL mypy_to_codeclimate-0.0.3.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e8447deac1d60e104bfb1233ea87cb6d9120a13c0082332c34585ff00036f85e
BLAKE2b-256 checksum
How to use checksums
0f0d17654bac6696021ea78b2c083bd7736a20fdc3d0f47a1d8a2def4e36f1b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.10.0 CPython/3.10.12

Release files / mypy_to_codeclimate-0.0.3-py3-none-any.whl

Download URL mypy_to_codeclimate-0.0.3-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6366cb48c816d95b54021218123080f5216c31d37322285256597a752cb40379
BLAKE2b-256 checksum
How to use checksums
353bee8335d853b68ec3b56df80c857e09eb4bc6d4206dba62aaac77610006f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.10.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page