diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 8e18d85..3dce9c5 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -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" diff --git a/README.md b/README.md index 87cbf90..78d063f 100644 --- a/README.md +++ b/README.md @@ -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