Add Ruff as a linter and formatter with pre-commit
This MR tries to solve the issue described in #115 (closed). Cerbero was originally pep8 conformant, but pre-CI days it was hard to enforce format consistency and over time it has become a bit of a mess.
The proposal is to use Ruff as a linter and formatter to check and fix the format. Ruff has been chosen because it's the fastest implementation, it's a formatter and linter, and it can apply fixes for both.
This MR also introduces the use of pre-commit to manage the pre-commit hooks and to use it in the CI.
Installation of hooks is straightforward. A user will run pre-commit install
to install the hooks and the CI will run pre-commit install-hooks
when creating the docker image to cache the hooks. Checks run automatically for users when creating a new commit and the CI will run pre-commit run --all-files
in the check sources
stage.
Hooks are configured in the pre-commit-config.yaml
file. New hooks can be easily added by editing this file without further action. Re-generating the CI's docker image will automatically install and cache all the required hooks' dependencies.
This MR introduces many format changes, but it's a price worth paying from my point of view.