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
🌐
pre-commit
pre-commit.com
pre-commit
Now whenever you clone a pre-commit enabled repo, the hooks will already be set up! $ git clone -q [email protected]:asottile/pyupgrade $ cd pyupgrade $ git commit --allow-empty -m 'Hello world!' Check docstring is first.............................(no files to check)Skipped Check Yaml...........................................(no files to check)Skipped Debug Statements (Python)............................(no files to check)Skipped ...
🌐
GitHub
github.com › pre-commit › pre-commit
GitHub - pre-commit/pre-commit: A framework for managing and maintaining multi-language pre-commit hooks. · GitHub
A framework for managing and maintaining multi-language pre-commit hooks. - pre-commit/pre-commit
Starred by 15.3K users
Forked by 975 users
Languages   Python 97.4% | R 2.0% | Shell 0.5% | Dockerfile 0.1% | Lua 0.0% | Ruby 0.0%
Discussions

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
pre commit.com - Should I install `pre-commit` into a python virtual environment or python global environment? - Stack Overflow
When I have a new python package ... with python -m venv .venv. I activate the venv using .venv\Scripts\activate. When working on the package I install package dependencies such as numpy with (.venv) C:\...\my_package> pip install numpy. I am trying to figure out how I should install the pre-commit package so ... More on stackoverflow.com
🌐 stackoverflow.com
What are some pre-commit hooks you run that you like?
We use Black formatting for python code. We have a pre-commit hook that looks at altered files and runs the formatter check on just those files. It just helps catch things before the PR check. There's also a pre-push that checks that generated code matches the configuration files used to generate it. We commit both so that we can see exactly what the outputs are, and require that the committed inputs produce the committed outputs. More on reddit.com
🌐 r/dataengineering
34
15
August 29, 2023
Using pre-commit hooks makes software development life easier
I find pre-commits very useful for the reason you mentioned in your other reply: failing fast (or shift left) philosophies. If there is a linting issue, it should be spotted before any CI is triggered. I use pre-commit when working with python with black (auto format), isort (for import sorting), flake8 (linting), and sometimes mypy for type checking. I disagree with the other comment about having save hooks on the ide because I save on every line change even if the change at that point would break everything. So it wouldn't make sense to perform any of the checks I perform with the pre-commit at that point. It's just a useful tool to use, it means CI runners aren't wasting time or compute resources failing jobs for things that could have been spotted before the commit was pushed. Yeah you can bypass, but that's why I will have the lint checks on the CI job too, it just means these checks are less likely to fail. More on reddit.com
🌐 r/programming
11
8
June 22, 2021
People also ask

How do I install pre-commit for a Python project?
Run `uvx pre-commit install` from the project root. This invokes pre-commit through uvx without adding it as a project dependency and writes a Git hook script to `.git/hooks/pre-commit`. The hook runs automatically on `git commit` against the project's `.pre-commit-config.yaml`.
🌐
pydevtools.com
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
How do I run pre-commit hooks in CI?
Add a GitHub Actions step that runs `uvx pre-commit run --all-files` after `actions/checkout@v4` and `astral-sh/setup-uv@v7`. Hooks run locally, but contributors can skip them with `git commit --no-verify`. Running the same hooks in CI ensures every change is checked before merge regardless of how it was committed.
🌐
pydevtools.com
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
How do I run mypy or ty as a pre-commit hook?
For mypy, use the `pre-commit/mirrors-mypy` repo and add any needed type stubs to `additional_dependencies`, for example `[types-requests]`. For ty, use a local hook that calls `uvx ty check` with `language: system` and `pass_filenames: false`, which lets ty discover files itself and respect any exclude patterns in your ty configuration.
🌐
pydevtools.com
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
🌐
PyPI
pypi.org › project › pre-commit
pre-commit · PyPI
A framework for managing and maintaining multi-language pre-commit hooks. These details have been verified by PyPI · asottile · These details have not been verified by PyPI · Homepage · License: MIT · Author: Anthony Sottile · Requires: Python >=3.10 ·
      » pip install pre-commit
    
Published   Apr 21, 2026
Version   4.6.0
🌐
Medium
medium.com › internet-of-technology › beautify-your-python-code-with-pre-commit-linters-a-step-by-step-guide-d63604d6120b
Pre-commit for Python | Internet of Technology
August 13, 2024 - First, activate your virtual environment. Then, install the pre-commit framework using pip: ... Now, we will add some Python packages for code quality checks.
🌐
Python for Data Science
python4data.science › en › latest › productive › git › advanced › hooks › pre-commit.html
pre-commit framework - Python for Data Science
April 24, 2026 - pre-commit is a framework for managing and maintaining multilingual commit hooks. An essential task is to make the same scripts available to the entire development team. pre-commit by yelp manages ...
Find elsewhere
🌐
DEV Community
dev.to › techishdeep › maximize-your-python-efficiency-with-pre-commit-a-complete-but-concise-guide-39a5
The Power of Pre-Commit for Python Developers: Tips and Best Practices - DEV Community
May 1, 2023 - As a software developer, ensuring high-quality and consistent code is vital for seamless operations. Precommit is a powerful tool that can assist in achieving this by automatically checking the code before it's committed.
🌐
Python Snacks
pythonsnacks.com › p › pre-commit-hooks-python
Using pre-commit hooks for your Python project
June 18, 2025 - A pre-commit hook is a small script that runs automatically before you commit your code using git.
🌐
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 - This guide assumes you have a Python project managed with uv. If you haven’t created a project yet, see the project creation tutorial. pre-commit is a framework that manages Git hooks.
🌐
Jakub Kriz
jakubk.cz › posts › pre_commit
Pre-commit in Python: Isolated Environments for Linters and Formatters | Jakub Kriz
February 14, 2025 - References Henry Ford’s quote: ... is a tool that automates code quality checks by managing Git hooks and consolidating formatters, linters, and type checkers through a centralized configuration file and isolated environments...
🌐
Python for Data Science
python4data.science › en › latest › productive › git › advanced › hooks › ci.html
pre-commit in CI pipelines - Python for Data Science
March 2, 2025 - stages: - validate pre-commit: stage: validate image: name: python:3.12 variables: PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit only: refs: - merge_requests - tags - main cache: paths: - ${PRE_COMMIT_HOME} before_script: - pip install pre-commit script: - pre-commit run --all-files ·
🌐
Towards Data Science
towardsdatascience.com › home › latest › pre-commit & git hooks: automate high code quality
Pre-Commit & Git Hooks: Automate High Code Quality | Towards Data Science
January 16, 2025 - Pre-commit is a useful Python package that improves your git hook workflow and simplifies your scripts. It is designed to keep the quality of your software high and remove the risk of bugs by automating your code-checking process.
🌐
Better Programming
betterprogramming.pub › 2-use-cases-of-python-pre-commit-hooks-to-tidy-up-your-git-repositories-8d86c9c4f06b
2 Use Cases of Python Pre-commit Hooks to Tidy Up Your Git Repositories | by Eldad Uzman | Better Programming
April 13, 2022 - Pre-commit is a python based tool that allows you to ‘hook’ into your git repository and trigger a simple code whenever changes are committed.
🌐
Talk Python To Me
talkpython.fm › episodes › show › 482 › pre-commit-hooks-for-python-devs
Episode #482 - Pre-commit Hooks for Python Devs | Talk Python To Me Podcast
October 24, 2024 - Stefanie’s focus on automated code quality checks led her to develop and share various pre-commit hooks, including a specialized one for NumPy docstrings and another for stripping EXIF metadata from images. Check out our course Up and Running with Git: While you don’t need deep Python expertise to use pre-commit hooks, having basic Git and Python knowledge will help you configure them effectively.
🌐
Artur's Blog
shiriev.ru › posts › 2024-12-14-pre-commit-in-python
Using pre-commit package in python development | Artur Shiriev
December 14, 2024 - Introduction. Package pre-commit, as stated on the github-page, is a framework for managing and maintaining multi-language pre-commit hooks. Mostly, it’s used for managing git hook right before commit to run some static checks or formatters.
🌐
Poetry
python-poetry.org › docs › pre-commit-hooks
pre-commit hooks | Documentation | Poetry - Python dependency management and packaging made easy
pre-commit hooks pre-commit is a framework for building and running git hooks. See the official documentation for more information: pre-commit.com This document provides a list of available pre-commit hooks provided by Poetry. Note If you specify the args: for a hook in your .pre-commit-co...
🌐
Scaling Celeste Mountain I
ljvmiranda921.github.io › notebook › 2018 › 06 › 21 › precommits-using-black-and-flake8
Automate Python workflow using pre-commits: black and flake8
June 21, 2018 - Before I commit my staged Python files, black formats my code and flake8 checks my compliance to PEP8. If everything passes, the commit is made. If not, then I the perform necessary edits and commit again. Less time is spent on code formatting so I can focus more on code logic.
🌐
Medium
medium.com › @guandika8 › create-clean-python-code-using-pre-commit-b3775f5a52f9
Create clean Python code using pre-commit | by Andika Wirawan | Medium
July 10, 2023 - Pre-commit is a powerful and flexible framework that can help you develop clean and consistent Python code. By using pre-commitments, you can automate various formatting checks and tools on your code before deploying it to a version control system.
🌐
Hotosm
docs.hotosm.org › dev-guide › repo-management › pre-commit
Pre-Commit - HOTOSM Docs
Pre-commit is a Python tool for simplifying and applying Git pre-commit hooks.