# ruff [![image](https://img.shields.io/pypi/v/ruff.svg)](https://pypi.python.org/pypi/ruff) [![image](https://img.shields.io/pypi/l/ruff.svg)](https://pypi.python.org/pypi/ruff) [![image](https://img.shields.io/pypi/pyversions/ruff.svg)](https://pypi.python.org/pypi/ruff) [![Actions status](https://github.com/charliermarsh/ruff/workflows/CI/badge.svg)](https://github.com/charliermarsh/ruff/actions) An extremely fast Python linter, written in Rust.

Bar chart with benchmark results

Linting the CPython codebase from scratch.

- ⚡️ 10-100x faster than existing linters - 🐍 Installable via `pip` - 🤝 Python 3.10 compatibility - 🛠️ `pyproject.toml` support - 📦 [ESLint](https://eslint.org/docs/latest/user-guide/command-line-interface#caching)-inspired cache support - 🔧 [ESLint](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix)-inspired `--fix` support - 👀 [TypeScript](https://www.typescriptlang.org/docs/handbook/configuring-watch.html)-inspired `--watch` support - ⚖️ [Near-complete parity](#Parity-with-Flake8) with the built-in Flake8 rule set Read the [launch blog post](https://notes.crmarsh.com/python-tooling-could-be-much-much-faster). ## Installation and usage ### Installation Available as [ruff](https://pypi.org/project/ruff/) on PyPI: ```shell pip install ruff ``` ### Usage To run ruff, try any of the following: ```shell ruff path/to/code/to/check.py ruff path/to/code/ ruff path/to/code/*.py ``` You can run ruff in `--watch` mode to automatically re-run on-change: ```shell ruff path/to/code/ --watch ``` ruff also works with [pre-commit](https://pre-commit.com): ```yaml repos: - repo: https://github.com/charliermarsh/ruff-pre-commit rev: v0.0.48 hooks: - id: lint ``` ## Configuration ruff is configurable both via `pyproject.toml` and the command line. For example, you could configure ruff to only enforce a subset of rules with: ```toml [tool.ruff] line-length = 88 select = [ "F401", "F403", ] ``` Alternatively, on the command-line: ```shell ruff path/to/code/ --select F401 --select F403 ``` See `ruff --help` for more: ```shell ruff: An extremely fast Python linter. Usage: ruff [OPTIONS] ... Arguments: ... Options: -v, --verbose Enable verbose logging -q, --quiet Disable all logging (but still exit with status code "1" upon detecting errors) -e, --exit-zero Exit with status code "0", even upon detecting errors -w, --watch Run in watch mode by re-running whenever files change -f, --fix Attempt to automatically fix lint errors -n, --no-cache Disable cache reads --select