Use Ruff for Python linting and formatting
Ruff is a widely used, extremely fast re-implementation of a number of Python tools like flake8, isort and black.
As proposed in #298 (closed) I changed the pre-commit configuration to use Ruff instead of the combination of the 3 tools flake8, isort and black.
The main differences wrt the previous configuration are
-
black
is replaced byruff format
command,isort
replacement is an autofixable lint check (ruff check --select I --fix filename.py
)- users never see this as it's wrapped in the
pre-commit
configuration
- users never see this as it's wrapped in the
- there are small differences between Ruff and isort+black
Somehow Ruff reported a number of type-comparison (E721) violations that were not reported by flake8/pycodestyle, so I fixed them (as well as a few more that were not reported), but we may want to reconsider it (see https://github.com/astral-sh/ruff/issues/6465).
Closes #298 (closed)
Edited by Marco Clemencic