Giter Site home page Giter Site logo

flake8-annotations's Introduction

Flake8 Problem Matcher/Annotations

Adds error and warning problem matchers for flake8 checks on Python projects. This action only generates Github Annotations from flake8 output, it does not run flake8.

Inputs

No inputs needed.

Outputs

Only Github Annotations are generated from the Checks output, no other output is generated.

Screenshot

Example annotations for file violations.py

Example usage

Add the following section to your Github workflow YAML in the step running flake8 before executing flake8:

    - name: Setup flake8 annotations
      uses: rbialon/flake8-annotations@v1

Example usage with Github's Python starter workflow:

name: Python application

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 3.8
      uses: actions/setup-python@v1
      with:
        python-version: 3.8
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt
    - name: Setup flake8 annotations
      uses: rbialon/flake8-annotations@v1
    - name: Lint with flake8
      run: |
        pip install flake8
        # stop the build if there are Python syntax errors or undefined names
        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
        flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
    - name: Test with pytest
      run: |
        pip install pytest
        pytest

flake8-annotations's People

Contributors

rbialon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flake8-annotations's Issues

does not annotate the Pull Request - only the whole repo

when running the GitHub action on a pull request annotations are generated for the whole repo and PR is marked as failed due to errors elsewhere. The action should add annotations on a PR only - on files modified by the PR

Flake8 plugins custom errors are not supported

I use flake8 plugins and they produce output that is not parsed by actions.

Thye use own letters for messages
D : flake8-docstrings==1.5.0
I: flake8-import-order==0.18.1
B: flake8-bandit==2.1.2

Here is an example:

foo.py:36:1: D400 First line should end with a period
foo:119:1: I100 Import statements are in the wrong order ...

I would like them to be annotated too.

I will just put some idea, I don't know if they are implementable:

  • Add a new problemMatcher for extra errors (always enabled).
  • Same as prev but has different version @v1 - > @x2
  • Add a new problemMatcher[s] and an option[s] to enable.
  • Add new option to specify the list of new error prefixes: 'BID' (I don't if it easy to do in the current infrastructure.)

The alternative solution is to write a new plugin for flake8 that will change the output. Like a plugin for TeamCity CI.

My use case is not very common, so won't fix is an option too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.