Ensure Python code quality. Supports mypy, pylint, black and isort.
Details
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 is a Python static code analysis tool which looks for programming errors, helps enforcing a coding standard, sniffs for code smells and offers simple refactoring suggestions.
Black is the uncompromising Python code formatter. Black makes code review faster by producing the smallest diffs possible.
isort is a Python utility / library to sort imports alphabetically, and automatically separated into sections and by type.
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 | "" |
django | Confirm if source is a Django project | false | false |
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 ore greater.
Low
- Must not have any type errors.
- Must not have any code format issues.
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
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
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",
django: true