Style guidelines
Style guidelines are enforced for both the backend and frontend code.
Code is automatically checked for style violations on commit (using pre-commit
and husky
).
All Pull Requests are also checked for style violations. Therefore it is important that you make sure your code is compliant with the style guidelines before you commit it.
Backend
All code is linted with quite strict PEP 8 (Style Guide for Python Code) and PEP 257 (Docstring Conventions) coding conventions.
To accommodate this a few tools are used.
- pylint to enforce the PEP's above
- mypy Static type checker
- flake8 to enforce the PEP's above
- Black is used for code formatting
- isort for sorted imports
- codespell to catch common misspellings
- pytest for testing
If you develop using the VSCode Dev Container all of the above tools are installed and configured for you.
If you develop outside of the Dev Container, I suggest that you setup your IDE to match these requirements which makes development faster and easier.
Run linters manually
You can use pre-commit
to run the Python linters manually.
To run all linters:
pre-commit run --all-files
To single out a specific linter (e.g. pylint
):
pre-commit run pylint --all-files
The Dev Container has Tasks configured for running the linters. You can run them from the Command Palette (Ctrl+Shift+P
or Cmd+Shift+P
).
Typing
Not all code is typed, but we are working towards typing all code. New code should be typed.
Frontend
All frontend code is linted with ESLint and formatted with Prettier.
Run linters manually
You can use npm
to run the TypeScript linters manually.
To run all linters:
npm run lint
To single out a specific linter (e.g. prettier
):
npm run lint:prettier
The Dev Container has Tasks configured for running the linters. You can run them from the Command Palette (Ctrl+Shift+P
or Cmd+Shift+P
).