Skip to content

Coding Style

Coding style
  • Pre-commit checks
  • Python style
  • Imports
  • Template style
  • View style
  • Model style
  • Use of django.conf.settings
  • Miscellaneous
  • JavaScript style

Coding style

Pre-commit checks

pre-commit is a framework for managing pre-commit hooks. These hooks help to identify simple issues before committing code for review. By checking for these issues before code review it allows the reviewer to focus on the change itself, and it can also help to reduce the number of CI runs.

To use the tool, first install pre-commit and then the git hooks:

$ python -m pip install pre-commit
$ pre-commit install

On the first commit pre-commit will install the hooks, these are installed in their own environments and will take a short while to install on the first run. Subsequent checks will be significantly faster. If an error is found an appropriate error message will be displayed. If the error was with black or isort then the tool will go ahead and fix them for you. Review the changes and re-stage for commit if you are happy with them.


Python style

  • All files should be formatted using the black auto-formatter. This will be run by pre-commit if that is configured.