- Keep lines under 80 characters.
- Prefer single quotes for string literals.
- Prefer f-strings over other formatting methods.
- Use triple double quotes for docstrings.
- In multi-line docstrings, place the opening """ on its own line.
- Make sure that:
- Private functions (name starting with
_) are only used internally within a module - Only functions that are used across different modules are public
- Private functions (name starting with
For any non-trivial change:
- Re-read all modified files.
- Simplify code where possible.
- Re-run relevant tests and checks.
- Fix issues locally rather than relying on CI.
Required checks:
flake8 <modified_python_files> && sourcery review <modified_files>- Keep commit messages short.
- Follow the style of recent commits in the repository.
- Use command line
git.
Run once per clone:
scripts/setup_local_hooks.sh This installs the pre-commit hook used to enforce local style checks.