![]() <!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> - `pre-commit-mirror-maker` is not suitable for generating multiple hooks in single `.pre-commit-hooks.yaml` file. - So replaced the script and github workflows. ## Test Plan <!-- How was it tested? --> - Update `pyproject.toml`'s `ruff==0.0.290` into `ruff==0.0.289`, and run the script. ```sh $ python3 mirror.py ... ``` |
||
---|---|---|
.github | ||
.gitignore | ||
.pre-commit-hooks.yaml | ||
LICENSE | ||
mirror.py | ||
pyproject.toml | ||
README.md | ||
requirements-dev.txt |
ruff-pre-commit
A pre-commit hook for Ruff.
Distributed as a standalone repository to enable installing Ruff via prebuilt wheels from PyPI.
Using Ruff with pre-commit
Add this to your .pre-commit-config.yaml
:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.291
hooks:
- id: ruff
Or, to enable autofix:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.291
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
To run the hook on Jupyter Notebooks too:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.291
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
Ruff's pre-commit hook should be placed after other formatting tools, such as Black and isort, unless you enable autofix, in which case, Ruff's pre-commit hook should run before Black, isort, and other formatting tools, as Ruff's autofix behavior can output code changes that require reformatting.
Using Ruff's formatter (unstable)
Ruff's formatter is in Alpha, but can used with pre-commit by adding the ruff-format
hook:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.291
hooks:
- id: ruff-format
To check formatting without changing files, use --check
:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.291
hooks:
- id: ruff-format
args: [--check]
Note v0.0.290
is the minimum version that provides the ruff-format
hook.
License
MIT