black-codeclimate
Convert the output of black --diff to a report conforming to the Code Climate spec.
It is made to be used in GitLab CI to generate a Code Quality report, which will show a nice widget in merge requests listing the file and the lines affected by the reformatting.
black-codeclimate uses unidiff to parse a diff file and detect changes, and outputs a JSON array of Code Climate issue objects reporting the filename and line range of the change. In theory it could be used on any unified diff data, but I only tested it with black --diff's output. Hit me up in the issues if you use it for anything else :)
Usage
Pipe the output of black --diff into black-codeclimate:
black --diff src/ | black-codeclimate > black_report.json
Or specify a file to use as input:
black-codeclimate black.diff > black_report.json
You can also change the severity, description and check_name of the issues in the resulting report by specifying command line flags:
black-codeclimate --severity blocker --description "would reformat [black]" --check-name "black" black.diff > black_report.json
Run black-codeclimate -h to see a list of the available flags.
Adding it to GitLab
Add this step to your .gitlab-ci.yml file:
lint:black:
stage: lint
before_script:
- # Install black and black-codeclimate...
script:
# --check fails the job if any inconsistent formatting is detected.
- black --diff --check src/ > black.diff
after_script:
- black-codeclimate black.diff > black_report.json
artifacts:
reports:
codequality: black_report.json
when: always
This will upload the black_report.json as a GitLab Code Quality artifact. The lines that would be reformatted by black will show up as a merge request widget.
Metadata
Release files for black-codeclimate 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| black_codeclimate-1.0.3.tar.gz | 4.3 kB | Without provenance | Details for black_codeclimate-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| black_codeclimate-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for black_codeclimate-1.0.3-py3-none-any.whl |
Total release size: 9.7 kB
Release files / black_codeclimate-1.0.3.tar.gz
| Download URL | black_codeclimate-1.0.3.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1cccba9928561502349e5b6c2d6f69b9c3cdd2f8a54864068a4b281c432e5055
|
|
BLAKE2b-256 checksum How to use checksums |
7a1a453564deb8a0849d9e9a02f79b3a11a37c9c82eae20837b23426dd942a0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.6 Darwin/23.2.0
|
Release files / black_codeclimate-1.0.3-py3-none-any.whl
| Download URL | black_codeclimate-1.0.3-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d99caf76f4c53d4e0ec513f6bc2cf58cca7c977cef36bf57e8d5143b6aee7521
|
|
BLAKE2b-256 checksum How to use checksums |
18d93eb2af0c8cf3e5020e894cf684f9f38b0ee592ff96b876b38c24be736935
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.6 Darwin/23.2.0
|
Security for black-codeclimate 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.