Linters
we should use several linters to make the coding style consistent. All configuration is stored inside setup.cfg
black
flake8 is used a general tool for linting
isort is used to validate
import
orderbandit for static security checks
Pre-Commit hooks
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: 19.3b0
hooks:
- id: black
Flake8
flake8 plugins
flake8-pytest - ensures that
pytest
best practices are usedflake8-pytest-style - ensures that
pytest
tests and fixtures are written in a single styleflake8-django - plugin to enforce best practices in a
django
project
MyPy
Mypy is an optional static type checker for Python that aims to combine the benefits of dynamic (or "duck") typing and static typing.
Installation and usage.
pip install dotenv-linter
And run it.
dotenv-linter .env .env.template
Examples
# Next line has leading space which will be removed:
SPACED=
# Equal signs should not be spaced:
KEY = VALUE
# Quotes won't be preserved after parsing, do not use them:
SECRET="my value"
# Beware of duplicate keys!
SECRET=Already defined ;(
# Respect the convention, use `UPPER_CASE`:
kebab-case-name=1
snake_case_name=2
Pre-Commit Hooks
repos:
- repo: https://github.com/wemake-services/dotenv-linter
rev: 0.2.0 # Use the ref you want to point at
hooks:
- id: dotenv-linter
Last updated
Was this helpful?