Style guide#
We aim to keep the cotainr code base and documentation consistent by following the style guides listed here.
We follow the PEP 8 style guide.
The Python source code is formatted using Ruff .
The codebase is linted with pre-commit.
All docstrings are formatted according to the numpydoc format.
We reference the python interpreter executable as python3 (not python) when explicitly calling the system python executable and as
sys.executablewhen reinvoking the interpreter as recommended in PEP 394.
When hacking on cotainr, we generally try to:
Error early.
Use self-describing commands and options.
Make it simple.
Specifically, we use the following conventions:
Force keyword only arguments to functions and methods.
Use relative imports within the cotainr package when importing functionality from other modules. The imports must be done such that all objects imported are still references (not copies) which allows for monkey patching objects in their definition module in tests.
pre-commit#
If you like, you can use pre-commit to automatically check and format your code as a git pre-commit hook. A simple way to install pre-commit and set up the hooks is to run something like
pip install pre-commit
pre-commit install
but this varies depending on your system and setup.
The pre-commit configuration is stored in .pre-commit-config.yaml in the root of the repository.
The CI/CD workflow in Test suite & CI/CD uses the same pre-commit configuration for linting and formatting.