Skip to content

Commit caa92de

Browse files
authored
Add alpha formatter support (astral-sh#50)
1 parent 9845d84 commit caa92de

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

.pre-commit-hooks.yaml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
- id: ruff
2-
name: ruff
3-
description: "Run 'ruff' for extremely fast Python linting"
4-
entry: ruff check --force-exclude
5-
language: python
6-
'types_or': [python, pyi]
7-
args: []
8-
require_serial: true
9-
additional_dependencies: []
10-
minimum_pre_commit_version: '2.9.2'
1+
- id: ruff
2+
name: ruff
3+
description: "Run 'ruff' for extremely fast Python linting"
4+
entry: ruff check --force-exclude
5+
language: python
6+
"types_or": [python, pyi]
7+
args: []
8+
require_serial: true
9+
additional_dependencies: []
10+
minimum_pre_commit_version: "2.9.2"
11+
- id: ruff-format
12+
name: ruff-format
13+
description: "Run 'ruff format' for extremely fast Python formatting"
14+
entry: ruff format --force-exclude
15+
language: python
16+
"types_or": [python, pyi]
17+
args: []
18+
require_serial: true
19+
additional_dependencies: []
20+
minimum_pre_commit_version: "2.9.2"

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,28 @@ _unless_ you enable autofix, in which case, Ruff's pre-commit hook should run _b
5050
and other formatting tools, as Ruff's autofix behavior can output code changes that require
5151
reformatting.
5252
53+
### Using Ruff's formatter (unstable)
54+
55+
[Ruff's formatter](https://github.com/astral-sh/ruff/blob/main/crates/ruff_python_formatter/README.md) is in Alpha, but can used with pre-commit by adding the `ruff-format` hook:
56+
57+
```yaml
58+
- repo: https://github.com/astral-sh/ruff-pre-commit
59+
rev: v0.0.289
60+
hooks:
61+
- id: ruff-format
62+
```
63+
64+
To check formatting without changing files, use `--check`:
65+
66+
```yaml
67+
- repo: https://github.com/astral-sh/ruff-pre-commit
68+
# Ruff version.
69+
rev: v0.0.289
70+
hooks:
71+
- id: ruff-format
72+
args: [--check]
73+
```
74+
5375
## License
5476

5577
MIT

0 commit comments

Comments
 (0)