Skip to main content

A flake8 formatter that turns output into Github Annotations

Project description

flake8-github-annotations

PyPI - Version PyPI - Python Version


A formatter plugin for flake8 that turns flake8 errors into Github Anotations.

Example Annotations

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-annotations

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:
  build:

    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-annotations

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.

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

flake8_github_annotations-0.0.1.tar.gz (714.4 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file flake8_github_annotations-0.0.1.tar.gz.

File metadata

File hashes

Hashes for flake8_github_annotations-0.0.1.tar.gz
Algorithm Hash digest
SHA256 cadb2292990354efe82c46aef9bd634d1e87fe464f064c3666ce0187672c2e5a
MD5 869eef004f5f9c33cbbcf8032e82904e
BLAKE2b-256 2ffdfac39a418991cd5f3815ed216116f67fae73e08d6e3f74c0cc376339ce15

See more details on using hashes here.

File details

Details for the file flake8_github_annotations-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_github_annotations-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5ee814af669643fcc98f65cf345ef0de5625a2f7e35a36cb7c56542bf132c74
MD5 2055bdb5408dd423366d2cb829fb4142
BLAKE2b-256 8dabf3a1189c2f1677ff1e6d691e7af1364de0bf12bf8ca93f3533f33b595792

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page