flake8-gl-codeclimate

raw JSON →
0.2.2 verified Fri May 01 auth: no python

Flake8 formatter that outputs GitLab Code Quality artifact JSON. Current version 0.2.2. Low release cadence; maintained primarily by the community.

pip install flake8-gl-codeclimate
error ModuleNotFoundError: No module named 'flake8_gl_codeclimate'
cause Package part of extras? Actually pip install flake8-gl-codeclimate works, but import path uses underscores.
fix
The correct import is from flake8_gl_codeclimate.formatter import CodeClimateFormatter.
error AttributeError: 'CodeClimateFormatter' object has no attribute 'format'
cause CodeClimateFormatter may not expose a public format() method; it's designed to be passed to flake8's --format.
fix
Use it via flake8 command: flake8 --format=codeclimate or subclass properly.
gotcha The formatter expects flake8's internal representation; calling formatter.format() directly may fail if flake8's LintResult structure changes.
fix Use via flake8's --format flag or with flake8's Result class.
deprecated Python 3.6 support is dropped in newer versions; ensure Python 3.7+.
fix Upgrade Python to 3.7+.

Create an instance of the formatter and use it to format flake8 results.

from flake8_gl_codeclimate.formatter import CodeClimateFormatter
formatter = CodeClimateFormatter()
print(formatter) # Outputs a JSON string of GitLab Code Climate issues