Skip to main content
Motus enforces code style automatically via ruff. This page documents the conventions that ruff does not catch.

Automated enforcement

Ruff handles formatting, import sorting, and pycodestyle. The active rule sets are: Ignored rules: E501 (line length) and E402 (module-level import position). The full configuration is in pyproject.toml under [tool.ruff].

Import ordering

Organize imports into four groups, separated by blank lines:
Ruff sorts imports within each group automatically. The TYPE_CHECKING block goes last and contains imports used only in type annotations.

Type annotations

Use modern Python 3.12+ syntax throughout:
Use TYPE_CHECKING guards for forward references that cause circular imports:

Naming conventions

Docstrings

Use Google style. Required for all public classes and functions.
Docstrings are not required for private helpers (prefixed with _) or test functions.

Comments

Add comments only where the logic is not self-evident from the code. Do not add comments to code you did not change. Prefer renaming variables or extracting functions over writing explanatory comments.

String formatting

Use f-strings for interpolation. Use explicit str.format() only when the template is defined separately from its arguments.