pip install pre-commit
Example of .pre-commit-config.yaml
:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/pylint
rev: pylint-2.8.1
hooks:
- id: pylint
args: ["--max-line-length=120", "--disable=import-error,missing-module-docstring,missing-function-docstring"]
There is another hook that is interesting but as of now conflicts with black
so I commented it out:
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.6.0
hooks:
- id: reorder-python-imports
language_version: python3
To run the pre-commit application:
pre-commit run --all-files