File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Ruff - Python linter and code formatter
2+
3+ ## Installing
4+
5+ Ruff can be invoked directly with ` uvx ` :
6+
7+ ``` bash
8+ $ uvx ruff check # Lint all files in the current directory.
9+ $ uvx ruff format # Format all files in the current directory.
10+ ```
11+
12+ This runs ` ruff ` as a ` uv ` tool without installing it (it's installed in a temporary environment and deleted after use).
13+
14+ Alternatively you can install with ` uv ` (recommended):
15+
16+ To install Ruff globally.
17+
18+ ``` bash
19+ $ uv tool install ruff@latest
20+ ```
21+
22+ ## Usage
23+
24+ ### Lint
25+
26+ ``` bash
27+ $ ruff check # Lint files in the current directory.
28+ $ ruff check --fix # Lint files in the current directory and fix any fixable errors.
29+ $ ruff check --watch # Lint files in the current directory and re-lint on change.
30+ $ ruff check path/to/code/ # Lint files in `path/to/code`.
31+ ```
32+
33+ For the full list of supported options, run ` ruff check --help ` .
34+
35+
36+ ### Formatter
37+
38+ ``` bash
39+ $ ruff format # Format all files in the current directory.
40+ $ ruff format path/to/code/ # Format all files in `path/to/code` (and any subdirectories).
41+ $ ruff format path/to/file.py # Format a single file.
42+ ```
43+
44+ For the full list of supported options, run ` ruff format --help ` .
45+
46+
47+ ### Sorting imports
48+
49+ ``` bash
50+ $ ruff check --select I --fix
51+ $ ruff format
52+ ```
You can’t perform that action at this time.
0 commit comments