Development

Pre-commit Hooks

The project uses pre-commit to ensure code quality. The hooks run automatically before each commit:

Hook

Description

flake8

PEP 8 static analysis (Tryton style: ignores E123, E124, E126, E128, E741, W503)

isort

Import sorting (VERTICAL_GRID, trytond prefix)

trailing-whitespace

Removes trailing whitespace

end-of-file-fixer

Ensures files end with a newline

check-xml-declaration

Ensures no space before ?> in XML declarations

check-xml-indentation

Ensures XML is indented with 4 spaces and no tabs

check-no-import-star

Disallows from M import *

check-docstring-quotes

Docstrings must use triple double quotes """

check-class-names

Ensures class names use CamelCase

Install pre-commit:

pip install pre-commit
pre-commit install

After installation, the hooks run automatically on every git commit. To run them manually:

pre-commit run --all-files

Tests

Tests are executed inside the Docker container using Invoke.

Run static analysis and unit tests for a single module:

inv tests --name speco

Run static analysis and unit tests for all modules:

inv tests

Run BDD (behave) tests for a single module:

inv bdd.run --name speco

Run BDD (behave) tests for all modules:

inv bdd.all

Build Documentation

Build the Sphinx documentation:

inv dev.docs

The generated documentation is available in backend/doc/_build/html/.