Python style guide#
Python code should adhere to PEP 8, with the following clarifications:
Use four spaces for indentation, no tabs.
Use Unix-style line endings (LF, aka
\\ncharacter).Spaces around operators (except for keyword arguments).
Use
CamelCasefor classes and exception types. Useunderscore_casefor everything else.
Automated formatting#
Python code should be automatically formatted and checked using ruff format and ruff check --fix, respectively. Merge request pipelines check code with both ruff format and ruff check to test for compliance.
Type hints#
All new code should include type hints and be checked with mypy. Merge request pipelines check code with mypy to test for compliance.
Exceptions to PEP 8#
- Line width:
Maximum width for lines is 99 (enforced by
ruff)
Docstrings#
Docstrings should be written using the Google docstring style. NumPy style docstrings are not supported.