Skip to content

astral-sh/ruff-pre-commit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ruff-pre-commit

Ruff image image image Actions status

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.278
  hooks:
    - id: ruff

Or, to enable autofix:

- repo: https://github.com/astral-sh/ruff-pre-commit
  # Ruff version.
  rev: v0.0.278
  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.278
  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.

License

MIT