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/.version b/.version index a81317b..ef63c3f 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.0.288 +0.0.290 diff --git a/README.md b/README.md index ac8b06b..19159ae 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # ruff-pre-commit [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) -[![image](https://img.shields.io/pypi/v/ruff/0.0.287.svg)](https://pypi.python.org/pypi/ruff) -[![image](https://img.shields.io/pypi/l/ruff/0.0.287.svg)](https://pypi.python.org/pypi/ruff) -[![image](https://img.shields.io/pypi/pyversions/ruff/0.0.287.svg)](https://pypi.python.org/pypi/ruff) +[![image](https://img.shields.io/pypi/v/ruff/0.0.290.svg)](https://pypi.python.org/pypi/ruff) +[![image](https://img.shields.io/pypi/l/ruff/0.0.290.svg)](https://pypi.python.org/pypi/ruff) +[![image](https://img.shields.io/pypi/pyversions/ruff/0.0.290.svg)](https://pypi.python.org/pypi/ruff) [![Actions status](https://github.com/astral-sh/ruff-pre-commit/workflows/main/badge.svg)](https://github.com/astral-sh/ruff-pre-commit/actions) A [pre-commit](https://pre-commit.com/) hook for [Ruff](https://github.com/astral-sh/ruff). @@ -18,7 +18,7 @@ Add this to your `.pre-commit-config.yaml`: ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.287 + rev: v0.0.290 hooks: - id: ruff ``` @@ -28,7 +28,7 @@ Or, to enable autofix: ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.287 + rev: v0.0.290 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] @@ -39,7 +39,7 @@ To run the hook on Jupyter Notebooks too: ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.287 + rev: v0.0.290 hooks: - id: ruff types_or: [python, pyi, jupyter] @@ -50,6 +50,31 @@ _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 + # Ruff version. + rev: v0.0.290 + 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.290 + hooks: + - id: ruff-format + args: [--check] +``` + +Note `v0.0.290` is the minimum version that provides the `ruff-format` hook. + ## License MIT diff --git a/setup.py b/setup.py index 9c3ecc2..1905625 100644 --- a/setup.py +++ b/setup.py @@ -6,5 +6,5 @@ setup( name='pre_commit_placeholder_package', version='0.0.0', - install_requires=['ruff==0.0.288'], + install_requires=['ruff==0.0.290'], )