flake8-github-annotations
A formatter plugin for flake8 that turns flake8 errors into Github Anotations.
Table of Contents
Installation
pip install flake8-github-annotations
Usage
To enable the formatter,
and turn flake8 output into Github Annotations,
provide the --format argument when invoking flake8.
flake8 --format github
This turns flake8 output into lines like this:
::error file=./src/flake8_github_annotations/file_with_error.py,line=1,col=1,title=F401::'collections' imported but unused
This is not useful when running flake8 locally, but will be turned into Github Annotations if ran in a GitHub Action.
You could add a Github Action like this .github/workflows/ci.yml:
name: Lint
on: [push]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: pip install flake8 flake8-github-annotations
- name: Lint with flake8
run: flake8 --format github
Running flake8 from a subdirectory
If you run flake8 from a subdirectory,
you need to provide the --github-annotation-path-prefix command line argument.
The provided path will be prefixed to the filenames in flake8 output,
so that GitHub correctly identifies the file locations.
For example, if flake8 is invoked from the subdirectory foo/bar in the structure,
below,
you should invoke it like so:
flake8 --format github --github-annotation-path-prefix foo/bar
repository_root
│
└───foo
└───bar
└───app.py
└───tox.ini
Alternative project
Using this project to format flake8 output makes the output hard to read for a human,
and you will probably need to call flake8 without the --format argument when linting
locally.
If you don't wish to add an extra argument to flake8 when running in CI, you can use the GithubAction rbialon/flake8-annotations, which uses regex to detect flake8 output. A drawback of this apporach is that the project currently (2023-03-29), only supports a predefined set of error code prefixes, and might not detect errors from your favourite flake8 plugin.
License
flake8-github-annotations is distributed under the terms of the MIT license.
Metadata
Release files for flake8-github-annotations 1.1.2
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 | |
|---|---|---|---|---|
| flake8_github_annotations-1.1.2.tar.gz | 23.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flake8_github_annotations-1.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.2 kB
Release files / flake8_github_annotations-1.1.2.tar.gz
| Download URL | flake8_github_annotations-1.1.2.tar.gz |
|---|---|
| Size | 23.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
338ac21bc265c8b262f6321281dc0dd75eb782349338ff51bb04ce1bc7d904f1
|
|
BLAKE2b-256 checksum How to use checksums |
c53775716847669078e192ebc0bb2fadce309097d7f9834eb6ed28ceec562f13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.2
|
Release files / flake8_github_annotations-1.1.2-py3-none-any.whl
| Download URL | flake8_github_annotations-1.1.2-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ff80423de8ef3887ec1effe613e70757bfc70aa79d030dca8ed78a86f3e118e
|
|
BLAKE2b-256 checksum How to use checksums |
4ea7efda0fb2348f413bc6e51bce41f0a6d2026b81770a513896e9ec7e0884f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.2
|
Security for flake8-github-annotations 1.1.2
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.