GithubHelp home page GithubHelp logo

lpherr / pylinter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arun51191/pylinter

0.0 0.0 0.0 69 KB

Enforce python linting on commits and pull requests, using flake8, mypy, and isort.

License: BSD 3-Clause "New" or "Revised" License

Dockerfile 7.63% Shell 92.37%

pylinter's Introduction

Copyright (c) 2021, Alexander Damiani

pylinter

made-with-python

Enforce python linting on commits and pull requests.

Linting Packages Used

Optional Inputs

  • python-root

    • directory to run linters on

    • by default mypy does not run recursively, but will here

  • flake8-flags

    • flags to run with flake8 command
  • mypy-flags

    • flags to run with mypy command
  • fail-on-isort

    • whether to fail job if isort changes needed

    • if set to false, isort will run and modify necessary files (auto-commit, shown below, can then be run to push changes)

  • skip-flake8

    • whether to skip flake8 checks

    • if set to true, job will not fail on flake8 errors

  • skip-mypy

    • whether to skip mypy checks

    • if set to true, job will not fail on mypy errors

  • skip-isort

    • whether to skip isort checks

    • if set to true, job will not fail on isort errors

  • mypy-ignore-dirs-files

    • list of directories and/or files to ignore for mypy. separate with spaces
  • requirements-file

    • requirements filepath needed to prevent mypy errors Library stubs are missing for package ...

    • ONLY need to include the missing library stubs (example: types-pyyaml)

    • it is recommended to create a seprate requirements_stubs.txt to use as input to prevent unnecessarily long execution time

    • default value is an emtpy string, meaning nothing is installed

Outputs

Print associated errors with failed job. The order of linters are flake8, mypy, isort. If any linter fails, the job will fail and no subsequent linters will run.

Quick Start

Default (no flags)

on: [push, pull_request]

jobs:
  python-lint:
    runs-on: ubuntu-latest
    name: CI workflow
    steps:
    - name: checkout source repo
      uses: actions/checkout@v2

    - name: linting
      uses: alexanderdamiani/[email protected]

Optional flags

on: [push, pull_request]

jobs:
  python-lint:
    runs-on: ubuntu-latest
    name: CI workflow
    steps:
    - name: checkout source repo
      uses: actions/checkout@v2

    - name: linting
      uses: alexanderdamiani/[email protected]
      with:
        python-root: '.'
        flake8-flags: '--count --show-source --statistics'
        mypy-flags: '--ignore-missing-imports'
        fail-on-isort: true
        mypy-ignore-dirs-files: 'folder1 folder2/main.py'

Auto-commit/push isort changes

on: [push, pull_request]

jobs:
  python-lint:
    runs-on: ubuntu-latest
    name: CI workflow
    steps:
    - name: checkout source repo
      uses: actions/checkout@v2

    - name: linting
      uses: alexanderdamiani/[email protected]
      with:
        python-root: '.'
        flake8-flags: '--count --show-source --statistics'
        mypy-flags: '--ignore-missing-imports'
        fail-on-isort: false

    - name: commit isort changes
      run: |
        git config --local user.email "[email protected]"
        git config --local user.name "GitHub Action"
        git add -A && git diff-index --cached --quiet HEAD || git commit -m 'isort'

    - name: push isort changes
      uses: ad-m/[email protected]
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        branch: ${{ github.ref }}

GITHUB_TOKEN

Included by default in every workflow to give access to the repo the workflow is running in. Does not need to be configured manually. Reference

License

BSD 3-Clause License

pylinter's People

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.