You may fancy me mad, but this is my standard python pre-commit stack: end-of-file-fixer trailing-whitespace fix-byte-order-marker mixed-line-ending name-tests-test no-commit-to-branch autoflake args: [ "--in-place", "--remove-unused-variables", "--remove-all-unused-imports" ] isort black cspell doc8 args: [ "--max-line-length", "112", "--file-encoding", "utf-8" ] flake8 additional_dependencies: [ flake8-pytest-style, flake8-bugbear, flake8-comprehensions, flake8-print, darglint ] bandit pylint Answer from Grintor on reddit.com
🌐
GitHub
github.com › astral-sh › ruff-pre-commit
GitHub - astral-sh/ruff-pre-commit: A pre-commit hook for Ruff. · GitHub
{ id = "ruff-format", types_or = ["python", "pyi"] }, ] See the section above on pre-commit for guidance on hook order when using --fix.
Starred by 1.9K users
Forked by 96 users
Languages   Python
🌐
Astral
docs.astral.sh › ruff › integrations
Integrations | Ruff
Ruff can be used as a pre-commit hook via ruff-pre-commit:
Discussions

python - Different results from Ruff between CLI and pre-commit hook - Stack Overflow
I've set up a pre-commit hook for using Ruff to handle linting in my project. I've configured the hook as per the documentation: - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.4.9 ... More on stackoverflow.com
🌐 stackoverflow.com
What are your favourite pre-commit hooks and why?
You may fancy me mad, but this is my standard python pre-commit stack: end-of-file-fixer trailing-whitespace fix-byte-order-marker mixed-line-ending name-tests-test no-commit-to-branch autoflake args: [ "--in-place", "--remove-unused-variables", "--remove-all-unused-imports" ] isort black cspell doc8 args: [ "--max-line-length", "112", "--file-encoding", "utf-8" ] flake8 additional_dependencies: [ flake8-pytest-style, flake8-bugbear, flake8-comprehensions, flake8-print, darglint ] bandit pylint More on reddit.com
🌐 r/Python
83
120
April 24, 2024
When to use pre-commit hook vs GitHub actions?
You should be using them both. Run pre-commit locally to run checks before committing to your local GitHub repository. Then run GitHub actions when you push and/or create a pull request to the remote repository on GitHub. I use tox to build Python projects with GitHub actions so that the entire build process can be checked across platforms. pre-commit doesn’t do that for me but it still does a lot to my code beforehand so this is why I use both. If the project builds successfully with GitHub actions using tox and all tests pass then I allow the pull request to be approved for merging. If anything fails it’s time to refactor the code and resubmit. More on reddit.com
🌐 r/Python
21
63
October 26, 2023
python poetry - Running git commit is not properly running pre-commit hooks - Stack Overflow
I'm currently using Ruff and am using pre-commit hooks to run it with configuration info in .pre-commit-config.yaml and .ruff.toml. When I run pre-commit run --all-files the rules like isort run fi... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Medium
medium.com › @kutayeroglu › automate-python-formatting-with-ruff-and-pre-commit-b6cd904b727e
Automate Python Formatting: with Ruff and pre-commit | by Kutay Eroğlu | Medium
April 30, 2025 - repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. rev: v0.11.7 hooks: # Run the formatter. - id: ruff-format ... Create a badly formatted Python file and commit changes.
🌐
PyPI
pypi.org › project › ruff
ruff · PyPI
- repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. rev: v0.15.12 hooks: # Run the linter. - id: ruff-check args: [ --fix ] # Run the formatter.
      » pip install ruff
    
Published   Apr 24, 2026
Version   0.15.12
🌐
Stack Overflow
stackoverflow.com › questions › 78637149 › different-results-between-cli-and-pre-commit
python - Different results from Ruff between CLI and pre-commit hook - Stack Overflow
Pre-commit runs only on the files in the git repo. So if a.py was not added to git, then it's only checked by ruff check and not pre-commit.
Find elsewhere
🌐
Towards AI
pub.towardsai.net › try-this-to-keep-your-python-code-clean-forever-eae201952c1e
Using Ruff in Pre-commit hooks and GitHub Actions | Towards AI
March 12, 2025 - Ruff can automatically clean your Python code if configured in Git pre-commit hooks or GitHub Actions. I use them both.
🌐
Astral
docs.astral.sh › ruff › tutorial
Tutorial | Ruff
This tutorial has focused on Ruff's command-line interface, but Ruff can also be used as a pre-commit hook via ruff-pre-commit:
🌐
GitHub
github.com › astral-sh › ruff
GitHub - astral-sh/ruff: An extremely fast Python linter and code formatter, written in Rust. · GitHub
March 14, 2026 - - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. rev: v0.15.12 hooks: # Run the linter. - id: ruff-check args: [ --fix ] # Run the formatter.
Starred by 47.4K users
Forked by 2K users
Languages   Rust 96.4% | Python 2.6% | TypeScript 0.9% | Shell 0.1% | CSS 0.0% | HTML 0.0%
🌐
YouTube
youtube.com › watch
Boost Your Python Code Quality: Pre-commit Tutorial (UV & Ruff) - YouTube
This video shows how to create a solid pre-commit setup for Python.Previous video containing the CI pipeline: https://www.youtube.com/watch?v=Y6D2XaFV3Cc🔗 C...
Published   November 28, 2024
🌐
Kilo59
kilo59.github.io › ruff-sync › pre-commit
Pre-commit - ruff-sync
In addition to syncing your Ruff configuration rules, ruff-sync can also automatically synchronize the version of the astral-sh/ruff-pre-commit hook in your .pre-commit-config.yaml to match the Ruff version installed in your project (e.g., from uv.lock or pyproject.toml).
🌐
GitHub
github.com › charliermarsh › ruff-pre-commit › blob › main › .pre-commit-hooks.yaml
ruff-pre-commit/.pre-commit-hooks.yaml at main · astral-sh/ruff-pre-commit
entry: ruff check --force-exclude · language: python · types_or: [python, pyi, jupyter] 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 ·
Author   astral-sh
🌐
GitHub
github.com › astral-sh › ruff-pre-commit › blob › main › README.md
ruff-pre-commit/README.md at main · astral-sh/ruff-pre-commit
{ id = "ruff-format", types_or = ["python", "pyi"] }, ] See the section above on pre-commit for guidance on hook order when using --fix.
Author   astral-sh
🌐
Reddit
reddit.com › r/python › when to use pre-commit hook vs github actions?
r/Python on Reddit: When to use pre-commit hook vs GitHub actions?
October 26, 2023 -

Hello! I’m working on a personal project and want to include features such as mypy, ruff, and auto runs of tests. As far as testing I’ve seen some cool integrations with GitHub actions. For ruff and mypy I’ve seen it go both ways in a pre-commit hook or in actions. Is there a standard for where ruff or mypy should be used?

🌐
Stack Overflow
stackoverflow.com › questions › 78753510 › running-git-commit-is-not-properly-running-pre-commit-hooks
python poetry - Running git commit is not properly running pre-commit hooks - Stack Overflow
I'm currently using pre-commit installed with Poetry, and am doing poetry install --with dev to install pre-commit. ... repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. rev: v0.5.0 hooks: # Run the linter. - id: ruff args: [ --fix ] # Run the formatter.
🌐
Reddit
reddit.com › r/python › recommending `prek` - the necessary rust rewrite of `pre-commit`
r/Python on Reddit: Recommending `prek` - the necessary Rust rewrite of `pre-commit`
October 15, 2025 -

Hi peeps,

I wanna recommend to all of you the tool prek to you. This is a Rust rewrite of the established Python tool pre-commit, which is widely used. Pre-commit is a great tool but it suffers from several limitations:

  1. Its pretty slow (although its surprisingly fast for being written in Python)

  2. The maintainer (asottile) made it very clear that he is not willing to introduce monorepo support or any other advanced features (e.g. parallelization) asked over the years

I was following this project from its inception (whats now called Prek) and it evolved both very fast and very well. I am now using it across multiple project, e.g. in Kreuzberg, both locally and in CI and it does bring in an at least x10 speed improvement (linting and autoupdate commands!)

So, I warmly recommend this tool, and do show your support for Prek by giving it a star!

🌐
Scientific Python Development
learn.scientific-python.org › development › guides › style
Style & static checks - Scientific Python Development Guide
Ruff, the powerful Rust-based linter, has a formatter that is designed with the help of some of the Black authors to look 99.9% like Black, but run 30x faster. Here is the snippet to add the formatter to your .pre-commit-config.yml (combine with the Ruff linter below):
🌐
PyDevTools
pydevtools.com › handbook › how-to › how-to-set-up-pre-commit-hooks-for-a-python-project
How to set up pre-commit hooks for a Python project | pydevtools
2 weeks ago - The ruff-check hook runs the linter with auto-fix enabled. The ruff-format hook runs the formatter. They execute in order, so linting fixes are applied before formatting. ... Run uvx pre-commit autoupdate periodically to update hook versions to the latest releases.
🌐
Medium
medium.com › @gnetkov › automating-code-quality-control-with-pre-commit-hooks-fdbc1ec5cfea
Automating Code Quality Control with Pre-commit Hooks | by Fedor GNETKOV | Medium
January 1, 2025 - Now, let me edit a Python file by adding some empty lines and then run all pre-commit hooks again. The result will be below. Ruff will format the file and notify us about it.