Linters

This project uses several linters to make coding style consistent. All configuration is stored inside setup.cfg and pyproject.toml.

ruff

We use ruff to format and lint our code.

To run:

ruff check && ruff format

See ruff docs on how to use it. The configuration is stored in pyproject.toml.

wemake-python-styleguide

wemake-python-styleguide is a flake8 based plugin. And it is also the strictest and most opinionated python linter ever. See wemake-python-styleguide docs.

Running linting process for all python files in the project:

flake8 .

django-migration-linter

We use django-migration-linter to find backward incompatible migrations. It allows us to write 0-downtime friendly code.

See django-migration-linter docs, it contains a lot of useful information about ways and tools to do it.

That’s how this check is executed:

python manage.py lintmigrations --exclude-apps=axes

Important note: you might want to exclude some packages with broken migrations. Sometimes, there’s nothing we can do about it.

yamllint

Is used to lint your yaml files. See yamllint docs.

yamllint -d '{"extends": "default", "ignore": ".venv"}' -s .

djlint

Is used to lint and format your html files. See djlint docs.

djlint --check server
djlint --lint server

dotenv-linter

Is used to lint your .env files. See dotenv-linter docs.

dotenv-linter config/.env config/.env.template

polint and dennis

Are used to lint your .po files. See polint docs. Also see dennis docs.

polint -i location,unsorted locale
dennis-cmd lint --errorsonly locale

Packaging

We also use pip and poetry self checks to be sure that packaging works correctly.

poetry check && pip check

Linters that are not included

Sometimes we use several other linters that are not included. That’s because they require another technology stack to be installed or just out of scope.

We also recommend to check the list of linters recommended by wemake-python-styleguide.

Here’s the list of these linters. You may still find them useful.

shellcheck

This linter is used to lint your .sh files. See shellcheck docs.

hadolint

This linter is used to lint your Dockerfile syntax. See hadolint