See documentation in the general section first.
For in-line comments, use Google style of Python DocStrings. Use DargLint and PyDocStyle pre-commit hooks for enforcing compliance and detecting style issues in DocStrings.
Python linter
Example config:
- repo: https://github.com/psf/black
rev: 21.11b1
hooks:
- id: black
args:
- --line-length=72Python formatter
Example config:
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
args:
# these settings are needed to make flake8 compatible with black
- --max-line-length=88
- --select=C,E,F,W,B,B950
- --extend-ignore=E203,E501DocStyle linter
Example config:
- repo: https://github.com/terrencepreilly/darglint
rev: v1.8.1
hooks:
- id: darglint
args:
- -v 2Additional linter (complementary to Darglint)
Example config:
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyleAutomatically upgrade syntax for newer versions of Python
Example config:
- repo: https://github.com/asottile/pyupgrade
rev: v2.29.1
hooks:
- id: pyupgradeApply a consistent format to setup.cfg files
Example config:
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.20.0
hooks:
- id: setup-cfg-fmtChecks for known vulnerabilities in used dependencies
Example config:
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
rev: v1.2.2
hooks:
- id: python-safety-dependencies-check