Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
code

GitHub Action

Flake8 with annotations

v2.1

Flake8 with annotations

code

Flake8 with annotations

Flake8 with annotations for Pull Request

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Flake8 with annotations

uses: TrueBrain/[email protected]

Learn more about this action in TrueBrain/actions-flake8

Choose a version

Flake8 with GitHub Actions -- including annotations for Pull Requests

GitHub License GitHub Tag GitHub commits since latest release

This GitHub Actions runs flake8 over your code. Any warnings or errors will be annotated in the Pull Request.

Usage

steps:
- uses: actions/checkout@v2
- uses: TrueBrain/actions-flake8@v2

By default, it uses the default Python version as installed on the GitHub Runner.

Different Python version

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
  with:
    python-version: 3.9
- uses: TrueBrain/actions-flake8@v2
  with:
    path: src

Parameter: flake8_version

In some cases you might want to pin a certain flake8 version.

This parameter is optional; by default the latest flake8 will be installed (if no flake8 is installed yet).

steps:
- uses: actions/checkout@v2
- uses: TrueBrain/actions-flake8@v2
  with:
    flake8_version: 3.8.0

Alternatively, you can pre-install flake8 before executing this action:

steps:
- uses: actions/checkout@v2
- run: pip install flake8==3.8.0
- uses: TrueBrain/actions-flake8@v2

If needed, this also allows you to install other flake8-plugins.

Parameter: path

Indicates the path to run flake8 in. This can be useful if your project is more than Python code.

This parameter is optional; by default flake8 will run on your whole repository.

steps:
- uses: actions/checkout@v2
- uses: TrueBrain/actions-flake8@v2
  with:
    path: src

Parameter: ignore

Indicates errors and warnings to skip.

This parameter is optional; by default no alerts will be ignored

steps:
- uses: actions/checkout@v2
- uses: TrueBrain/actions-flake8@v2
  with:
    ignore: E4,W

Parameter: max_line_length

Indicates the maximum allowed line length.

This parameter is optional; by default flake8's default line length will be used.

steps:
- uses: actions/checkout@v2
- uses: TrueBrain/actions-flake8@v2
  with:
    max_line_length: 90

Parameter: only_warn

Only warn about problems. All errors and warnings are annotated in Pull Requests, but it will act like everything was fine anyway. (In other words, the exit code is always 0.)

This parameter is optional; setting this to any value will enable it.

steps:
- uses: actions/checkout@v2
- uses: TrueBrain/actions-flake8@v2
  with:
    only_warn: 1

Parameter: plugins

List of plugins to install before running, This is passed directly to pip install.

This parameter is optional; setting this to any value will enable it.

steps:
- uses: actions/checkout@v2
- uses: TrueBrain/actions-flake8@v2
  with:
    plugins: flake8-bugbear cohesion==0.9.1

Parameter: error_classes

List of flake8 error classes to classify as Error.

This parameter is optional; by default E and F classes will be considered errors.

steps:
- uses: actions/checkout@v2
- uses: TrueBrain/actions-flake8@v2
  with:
    error_classes: E,H

Parameter: warning_classes

List of flake8 error classes to classify as Warning.

This parameter is optional; by default all classes not contained in error_classes will be considered a warning.

steps:
- uses: actions/checkout@v2
- uses: TrueBrain/actions-flake8@v2
  with:
    warning_classes: W,B,D