Mypy GitLab Code Quality

1.3.0 · active · verified Wed Apr 15

mypy-gitlab-code-quality is a simple Python script designed to generate a GitLab Code Quality report from the output of Mypy, the static type checker for Python. The current version is 1.3.0, released on March 31, 2025. It appears to have a regular, though not rapid, release cadence, primarily updating to ensure compatibility with Mypy and GitLab's Code Quality specifications.

Warnings

Install

Imports

Quickstart

This example demonstrates how to integrate `mypy-gitlab-code-quality` into a GitLab CI/CD pipeline. It installs `mypy` and `mypy-gitlab-code-quality`, runs `mypy` on `program.py` (ensuring JSON output), then pipes that output to `mypy-gitlab-code-quality` to generate `codequality.json`. This JSON file is declared as a `codequality` artifact for GitLab to parse and display in merge requests. The `allow_failure: true` setting is recommended for code quality jobs.

image: python:alpine

codequality:
  script:
    - pip install mypy mypy-gitlab-code-quality
    # Run mypy and capture its JSON output to a temporary file
    - mypy program.py --output=json > mypy-out.json || true # '|| true' prevents job failure if mypy finds errors
    # Process mypy output into GitLab Code Quality format and redirect to 'codequality.json'
    - mypy-gitlab-code-quality < mypy-out.json > codequality.json
  artifacts:
    when: always
    reports:
      codequality: codequality.json
  allow_failure: true # Recommended for code quality jobs to not block pipelines

view raw JSON →