Code formatter.
Format back-end/src
code using scripts/format.sh
.
Pass -c | --check
flag to check for code style conformance.
If you use PyCharm
, be sure to turn off auto formatter:
- Navigate to
Settings / Preferences
>Appearance & Behavior
>Scopes
. - Add new scope with name
python
and patternfile:*.py
. - Navigate to
Settings / Preferences
>Editor
>Code Style
>Formatter Control
. - Add created
python
scope.
Code linter.
Lint code for the entire back-end
using scripts/lint.sh
or manually specify directories and modules/files:
pylint conf dms/models.py
In order to display a help message for the given message id, pass it to --help-msg
option:
pylint --help-msg=<id>
For example:
$ scripts/lint.sh
dms/admin.py:3:0: E5142: User model imported from django.contrib.auth.models (imported-auth-user)
$ pylint --help-msg=E5142
:imported-auth-user (E5142): *User model imported from django.contrib.auth.models*
Don't import django.contrib.auth.models.User model. Use
django.contrib.auth.get_user_model() instead! This message belongs to the
auth-user-checker checker.
Lint settings can be found in .pylintrc
.
Test framework.
Run tests for the entire back-end
using scripts/test.sh
.
We use default pytest
and Django-specific addon pytest-django
.