Coding Conventions¶
The following guidelines apply to code contributions to the Robusta engine itself.
Formatting¶
Robusta uses Black and ISort to automatically format code. Please set up Black prior so that all your contributions to Robusta will be formatted properly.
For instructions on using those tools with your IDE, see:
Linting¶
Robusta uses Flake8 and PyRight for code linting and type checking. Please set up Flake8 and PyRight prior so that all your contributions to Robusta will be linted properly.
For instructions on using Flake8 and PyRight tools with VSCode:
For instructions on using Flake8 and PyRight tools with PyCharm, see:
Pre-Commit Hooks¶
Robusta uses pre-commit to run Black, ISort, Flake8 and PyRight (and some other minor hooks) before each commit.
To do so, install Robusta's dependencies with cd src/ && poetry install
and then install the hook by running pre-commit install
Data classes¶
Use pydantic.BaseModel
instead of Python dataclasses
when possible. Pydantic performs datavalidation whereas Python dataclasses
just reduce boilerplate code like defining __init__()
Imports¶
Use absolute imports whenever possible. For example, instead of from . import foo
, use from robusta import foo
To help with that, pre-commit hook will automatically fix relative imports to absolute imports.