Development

This repository uses multiple automatic tools in order to reach a high standard. The tools used are:

  1. ruff as a linter & formatter for the code.

  2. mypy is used for type validation.

There is also pre-commit hook which uses executes ruff automatically before every commit. In order to activate this hook one should execute the following command:

pre-commit install

This tool installs into .git/hooks/ the hook which activates ruff.

There is an issue when it comes to using mypy as a pre-commit hook as well, for more details you can look at this issue.

In earlier stages of this project, we’ve used black, isort & pylint, however we’ve seen that ruff offers the same functionality (and more) but takes only a fraction of the execution time (real world, wall clock time). Even though we’ve ditched isort & black in favor of ruff you can still use them since ruff maintains compatibility with those tools. You could also still use pylint as it isn’t checks the same rules as ruff and the project still maintains a high score of over 9.9 with pylint.

Executation of Automatic Tools by Hand

All the automatic tools can be also used manually as follows:

Automatic Tool Name

Purpose of the Tool

Commands

Replaced by ruff

Ruff

Formatted & Linter

ruff check --preview .
ruff format .

mypy

Types Validation

mypy .

No

Black

Formatter

black .

Yes

isort

Formatter of import statements

isort .

Yes

pylint

Linter

pylint .

Yes (Partially)

Using Pre-Commit Git Hooks

We use pre-commit instead of some CICD like Github Action or Travis CI since We haven’t configured any runners yet. However enforcing the usage of those automatic tools is still very important and therefore we’ve settled for enforcing them through git hooks. In order to allow those hooks you should execute the following command once (the installation of the hook).

Purpose

Command

Install the hook (needs to be executed only once)

pre-commit install

Uninstall the hook

pre-commit uninstall

Run all checks on the entire repository

pre-commit run --all-files

Note

By default pre-commit tries to optimize the actual time it takes to run the checks by running them ONLY on the editted files rather than on the entire repository.