ruff

Contents

ruff#

Ruff is a Python linter and formatter implemented in the Rust programming language. It is very fast and incorporates over 800 linting rules. It can be used as full replacement for several other tools, including flake8 and pydocstyle and black.

Usage#

Use the ruff check command to lint a given file or project directory.

$ ruff check some_file.py
$ ruff check
$ ruff check --fix  # run the linter and fix errors when possible

Use the ruff format command to format your project’s code.

$ ruff format

Use pyproject.toml to customize the settings.

[tool.ruff]
line-length = 100  # increase max line length from 88 to 100 characters

[tool.ruff.lint]
extend-select = ["D", "PTH"]  # also include pydocstyle "D" and pathlib "PTH" rules
ignore = ["D107", "D301"]  # ignore specific rules

[tool.ruff.pydocstyle]
convention = "pep257"  # select docstyle convention