Skip to main content

Simple script to generate gitlab code quality report from output of mypy.

Project description

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

mypy-gitlab-code-quality

Simple script to generate gitlab code quality report from output of mypy.

Example gitlab codequality report from gitlab documentation: Example gitlab codequality report

Usage

$ mypy program.py | PYTHONHASHSEED=0 mypy-gitlab-code-quality

This command send to STDOUT generated json that can be used as Code Quality report artifact.

Note: Set environment variable PYTHONHASHSEED to 0 to prevent randomize hashes. Constant hashes allow gitlab to determine diff between branches on merge request.

Example .gitlab-ci.yml

image: python:alpine
variables:
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

cache:
  paths:
    - .cache/pip/
    - venv/
    - .mypy_cache/

before_script:
  - python --version  # For debugging
  - python -m venv venv
  - . venv/bin/activate

codequality:
  script:
    - pip install mypy mypy-gitlab-code-quality
    - mypy program.py --no-error-summary > mypy-out.txt
    - PYTHONHASHSEED=0 mypy-gitlab-code-quality < mypy-out.txt > codequality.json
  artifacts:
    when: always
    reports:
      codequality: codequality.json
  allow_failure: true

Note: if you want to use this example you should replace program.py with yours module names.

Contributing

Please run linters before creating merge request

pip install requirements/dev.txt
black .
mypy .
ruff .

Suggestions and merge requests are always welcome :)

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-gitlab-code-quality-1.0.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

mypy_gitlab_code_quality-1.0.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file mypy-gitlab-code-quality-1.0.0.tar.gz.

File metadata

File hashes

Hashes for mypy-gitlab-code-quality-1.0.0.tar.gz
Algorithm Hash digest
SHA256 64b9a5ad340740b694ee3b04ee9691c58244413bafa485fbe7d9632f5b3dd654
MD5 7a2a53ec085bf93f9228a5d196a1f3ee
BLAKE2b-256 2d435f3cc26f028da7cf30eba5b7fd3554183f8c1638dbb0c5e38d0d25292768

See more details on using hashes here.

File details

Details for the file mypy_gitlab_code_quality-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mypy_gitlab_code_quality-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a8c55f8c83d95890cdf5e78b9d8a90629658bc63cba5df7ab56f63828a55538
MD5 77b2e77c20e7ae2cb2569d72d61c6485
BLAKE2b-256 c4d8129c340a4d51f1a622b98cd310d14854c3bae86b9a1f0ce28c5622ac4257

See more details on using hashes here.

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