mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-31 00:43:47 +00:00
1.2 KiB
1.2 KiB
Using Ruff
To run Ruff, try any of the following:
ruff check . # Lint all files in the current directory (and any subdirectories)
ruff check path/to/code/ # Lint all files in `/path/to/code` (and any subdirectories)
ruff check path/to/code/*.py # Lint all `.py` files in `/path/to/code`
ruff check path/to/code/to/file.py # Lint `file.py`
You can run Ruff in --watch
mode to automatically re-run on-change:
ruff check path/to/code/ --watch
Ruff can also be used as a pre-commit hook:
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.255'
hooks:
- id: ruff
Or, to enable autofix:
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.255'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Note that Ruff's pre-commit hook should run before Black, isort, and other formatting tools.
Ruff can also be used as a VS Code extension or alongside any other editor through the Ruff LSP.