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
Starred by 15.2K users
Forked by 961 users
Languages Python 97.4% | R 2.0% | Shell 0.5% | Dockerfile 0.1% | Lua 0.0% | Ruby 0.0%
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
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
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
is there a python pre-commit tool that can change all relative imports to absolute imports within a project?
https://stackoverflow.com/a/66026470 The repo is archived, but who knows, it might still work :p More on reddit.com
Videos
04:52
How to Run a Python Script Upon Commit Using a Pre-Commit Hook ...
04:45
Boost Your Python Code Quality: Pre-commit Tutorial (UV & Ruff) ...
12:23
Pre-Commit: Enforce coding best-practices - YouTube
08:36
1. Pre-commit Hooks for Python Projects. - YouTube
29:19
Pre Commit Hooks EXPLAINED | Easy Way Clean Repo! GitHub & PyCharm ...
01:10:03
Pre-commit Hooks for Python Devs - Talk Python to Me Ep.482 - YouTube
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
Reddit
reddit.com › r/python › what are your favourite pre-commit hooks and why?
r/Python on Reddit: What are your favourite pre-commit hooks and why?
April 24, 2024 -
Just getting started with pre-commit and I think it's awesome. Looking to find out what other code automation tools people are using. Let me know what works for you and why. Thanks!
Top answer 1 of 24
65
black Particularly useful on projects with multiple collaborators because everyone’s code will be formatted identically.
2 of 24
53
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
Typicode
typicode.github.io › husky
Husky
Automatically lint your commit messages, code, and run tests upon committing or pushing.
Claude
code.claude.com › docs › en › best-practices
Best practices for Claude Code - Claude Code Docs
1 week ago - Have Claude list all files that need migrating (e.g., list all 2,000 Python files that need migrating) ... for file in $(cat files.txt); do claude -p "Migrate $file from React to Vue. Return OK or FAIL." \ --allowedTools "Edit,Bash(git commit *)" done
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 ·
Principles of Visualization
ericmjl.github.io › essays-on-data-science › terminal › pre-commits
Using pre-commit git hooks to automate code checks - Essays on Data Science
conda install -c conda-forge pre-commit pre-commit sample-config > .pre-commit-config.yaml pre-commit install pre-commit run --all-files · While the default set is nice, you might want to install other hooks. For example, a Python project might want to default to using black as the code formatter.
GitHub
github.com › pre-commit › pre-commit › releases
Releases · pre-commit/pre-commit
pre-commit hook-impl: allow --hook-dir to be missing to enable easier usage with git 2.54+ git hooks. ... There was an error while loading. Please reload this page. ... There was an error while loading. Please reload this page. ... Fix language: python with repo: local without additional_dependencies.
Author pre-commit
Git LFS
git-lfs.com
Git Large File Storage | Git Large File Storage (LFS) replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitHub.com or GitHub Enterprise.
Note that defining the file types Git LFS should track will not, by itself, convert any pre-existing files to Git LFS, such as files on other branches or in your prior commit history.
Pitivi
developer.pitivi.org › Precommit_hooks.html
pre-commit hooks
To update pylint, follow the instructions for updating the Python dependencies. To update the regular hooks, take the repos one by one, check what is the latest version and update the entry in the .pre-commit-config.yaml file.
Readthedocs
jupytext.readthedocs.io › en › latest › using-pre-commit.html
Pre-commit hook — Jupytext documentation
You don’t need Jupytext’s pre-commit hook if you commit only the .py (or .md) representation of notebooks in your Git repository.
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.