Ruff
An extremely fast Python linter and code formatter, written in Rust.
What is it used for here?
!
linting
Python code to enforce coding standards and catch potential errorsformatting
Python code to ensure consistent style- сhecking code quality before every commit and during CI pipelines
How to use it?
- In this case, the Makefile does the same as running the commands directly via uv. The Makefile is only needed to shorten commands.
!
How to use it with pre-commit?
To use Ruff with pre-commit, you need to add a configuration for it in your .pre-commit-config.yaml
file.
!
.pre-commit-config.yaml
- repo: local
hooks:
# lint code
- id: ruff
name: Ruff
description: Run Ruff for linting Python code
entry: uv run ruff check
types: [python]
language: system
always_run: true
pass_filenames: false
args: [ --config=pyproject.toml, ./src/ ]
# format code
- id: ruff
name: Ruff
description: Run Ruff for formatting Python code
entry: uv run ruff format
types: [python]
language: system
always_run: true
pass_filenames: false
args: [ --config=pyproject.toml, ./src/ ]
Configuration
All configuration for Ruff in this template is located in pyproject.toml under the [tool.ruff]
section.
For more details on configuration, see the Ruff Documentation