Add alpha formatter support (#50)

This commit is contained in:
Zanie Blue 2023-09-12 15:49:39 -05:00 committed by GitHub
parent 9845d84394
commit caa92debff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 10 deletions

View File

@ -1,10 +1,20 @@
- id: ruff
name: ruff
description: "Run 'ruff' for extremely fast Python linting"
entry: ruff check --force-exclude
language: python
'types_or': [python, pyi]
args: []
require_serial: true
additional_dependencies: []
minimum_pre_commit_version: '2.9.2'
- id: ruff
name: ruff
description: "Run 'ruff' for extremely fast Python linting"
entry: ruff check --force-exclude
language: python
"types_or": [python, pyi]
args: []
require_serial: true
additional_dependencies: []
minimum_pre_commit_version: "2.9.2"
- id: ruff-format
name: ruff-format
description: "Run 'ruff format' for extremely fast Python formatting"
entry: ruff format --force-exclude
language: python
"types_or": [python, pyi]
args: []
require_serial: true
additional_dependencies: []
minimum_pre_commit_version: "2.9.2"

View File

@ -50,6 +50,28 @@ _unless_ you enable autofix, in which case, Ruff's pre-commit hook should run _b
and other formatting tools, as Ruff's autofix behavior can output code changes that require
reformatting.
### Using Ruff's formatter (unstable)
[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:
```yaml
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.289
hooks:
- id: ruff-format
```
To check formatting without changing files, use `--check`:
```yaml
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.289
hooks:
- id: ruff-format
args: [--check]
```
## License
MIT