Giter Site home page Giter Site logo

jaykv / python-linter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sunnysid3up/python-linter

1.0 0.0 0.0 16 KB

A GitHub Action which ensures Python code quality and supports customizable strictness.

Home Page: https://github.com/marketplace/actions/python-linter

License: MIT License

Shell 81.84% Dockerfile 18.16%

python-linter's Introduction

Python Linter

Ensure Python code quality. Supports mypy, pylint, black and isort.

Details

mypy

Mypy is an optional static type checker for Python. You can add type hints (PEP 484) to your Python programs, and use mypy to type check them statically. Find bugs in your programs without even running them!

pylint

Pylint is a Python static code analysis tool which looks for programming errors, helps to enforce a coding standard, sniffs for code smells and offers simple refactoring suggestions.

black

Black is the uncompromising Python code formatter. Black makes code review faster by producing the smallest diffs possible.

isort

isort is a Python utility / library to sort imports alphabetically, and automatically separated into sections and by type.

Configuration

Options

Name Description Optional Default
source Source file or directory false "."
strict Set strictness for lint [low, medium, high] false "medium"
mypy-options Mypy options false ""
pylint-options Pylint options false ""
black-options Black options false ""
isort-options Isort options false ""

Strictness

High

  • Must not have any type errors.
  • Must not have any code format issues.
  • Must not have import disorganization.
  • Must meet code standard style (PEP8). Code must have a Pylint score of 10.

Medium (default)

  • Must not have any type errors.
  • Must not have any code format issues.
  • Must not have import disorganization.
  • Code must have a Pylint score of 8 or greater.

Low

  • Must not have any type errors.
  • Must not have any code format issues.

(Optional) More pylint customization

Create a setup.cfg or a .pylintrc file in the current working directory.

[pylint]
ignore=
    migrations,
    manage.py,
    __init__.py,
    apps.py,
    admin.py,
    models.py,
    serializers.py,
    urls.py,
disable=
    import-error,
    missing-module-docstring,
    missing-function-docstring

(Optional) More isort customization

Create a setup.cfg or a .isort.cfg file in the current working directory.

[isort]
include_trailing_comma=True
known_first_party=app
lines_between_sections=0
lines_between_types=0
known_django=django
known_drf=rest_framework
line_length=100
multi_line_output=3
sections=FUTURE,STDLIB,DJANGO,DRF,THIRDPARTY,FIRSTPARTY,LOCALFOLDER

Example

 steps:
 - uses: actions/checkout@v2  
 - name: Python Linter
   uses: sunnysid3up/python-linter@master
   with:
     source: "src"
     mypy-options: "--ignore-missing-imports --show-error-codes"
     pylint-options: "--rcfile=setup.cfg"
     isort-options: "-w 100"

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.