Linters

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

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.

Things that are included in the linting process:

  • flake8 is used a general tool for linting

  • isort is used to validate import order

  • bandit for static security checks

  • eradicate to find dead code

  • and more!

Running linting process for all python files in the project:

flake8 .

Extra plugins

We also use some extra plugins for flake8 that are not bundled with wemake-python-styleguide:

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