🌐
pre-commit
pre-commit.com
pre-commit
For each language, they default to using the system installed language (So for example if I’m running python3.7 and a hook specifies python, pre-commit will run the hook using python3.7). Sometimes you don’t want the default system installed version so you can override this on a per-hook basis by setting the language_version. - repo: https://github.com/pre-commit/mirrors-scss-lint rev: v0.54.0 hooks: - id: scss-lint language_version: 2.1.5
🌐
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.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%
🌐
GitHub
github.com › pre-commit
pre-commit · GitHub
Python 293 MIT 173 3 1 Updated · Apr 28, 2026 · pre-commit.com Public · There was an error while loading. Please reload this page. pre-commit/pre-commit.com’s past year of commit activity · Python 205 306 3 (1 issue needs help) 2 Updated · Apr 28, 2026 ·
🌐
GitHub
github.com › pre-commit › pygrep-hooks
GitHub - pre-commit/pygrep-hooks: A collection of fast, cheap, regex based pre-commit hooks. · GitHub
- repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 # Use the ref you want to point at hooks: - id: python-use-type-annotations # ... Where possible, these hooks will be prefixed with the file types they target.
Starred by 239 users
Forked by 40 users
Languages   Python
🌐
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 - Define precommit hooks: Now, you can define the hooks that precommit will run. For example, you can add a hook to format your code using black. You can also add a hook to lint your code using a tool flake8 .
🌐
GitHub
github.com › pre-commit › pre-commit-hooks
GitHub - pre-commit/pre-commit-hooks: Some out-of-the-box hooks for pre-commit · GitHub
Prevent giant files from being committed. Specify what is "too large" with args: ['--maxkb=123'] (default=500kB). Limits checked files to those indicated as staged for addition by git. If git-lfs is installed, lfs files will be skipped (requires git-lfs>=2.2.1) --enforce-all - Check all listed files not just those staged for addition. Simply check whether files parse as valid python...
Starred by 6.5K users
Forked by 789 users
Languages   Python
🌐
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 - Navigate to the root of your repo and create a .pre-commit-config.yaml within your project. You can do this by running the following command: ... This file will define what you want to run before committing your code. An example looks like this: repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v2.3.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/psf/black rev: 22.10.0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 rev: v6.0.0 hooks: - id: flake8 additional_dependencies: [flake8-docstrings, flake8-import-order] args: ['--max-line-length=88']
🌐
GitHub
github.com › pre-commit › pre-commit › issues › 1245
How to run a local python file · Issue #1245 · pre-commit/pre-commit
December 18, 2019 - Hi, I am sorry if this is obvious but I am trying to run a simple python file for our project using pre-commit. Essentially I want a git prehook to create a csv file every time it gets committed. S...
Author   drummerboy2543
🌐
Poetry
python-poetry.org › docs › pre-commit-hooks
pre-commit hooks | Documentation | Poetry - Python dependency management and packaging made easy
A .pre-commit-config.yaml example for a monorepo setup or if the pyproject.toml file is not in the root directory: repos: - repo: https://github.com/python-poetry/poetry rev: '' # add version here hooks: - id: poetry-check args: ["-C", "./subdirectory"] - id: poetry-lock args: ["-C", "./subdirectory"] - id: poetry-export args: ["-C", "./subdirectory", "-f", "requirements.txt", "-o", "./subdirectory/requirements.txt"] - id: poetry-install args: ["-C", "./subdirectory"] pre-commit autoupdate updates the rev for each repository defined in your .pre-commit-config.yaml to the latest available tag in the default branch.
Find elsewhere
🌐
Medium
medium.com › @anton-k. › how-to-set-up-pre-commit-hooks-with-python-2b512290436
How to set up pre-commit hooks with Python? | by Anton K | Medium
April 26, 2022 - repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.2.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - id: check-merge-conflict - id: check-ast - id: double-quote-string-fixer - id: debug-statements - id: check-toml - id: check-json - id: check-xml · Here I added seven new hooks. Most of them are nice to have in every python project.
🌐
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 - In this short post, I’ll describe how I created a pre-commit pipeline in PySwarms using the black code formatter, flake8 checker, and the pre-commit Python framework.
🌐
GitHub
gist.github.com › Ytosko › 0e1fb692199f4557bb18081c838cb875
Automating Your Workflow with Git Pre-Commit Hooks and Python · GitHub
# See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/psf/black rev: 24.3.0 # Use a recent stable version hooks: - id: black args: [--check] # This runs black in check-only mode types: [python] - repo: https://github.com/pycqa/flake8 rev: 7.0.0 # Use a recent stable version hooks: - id: flake8 types: [python]
🌐
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 - Don’t forget to update the rev tags to the latest versions, available in the packages GitHub repositories under Releases: ... Oliver Lövström. ... Now, each git commit will automatically trigger the pre-commit checks. Finally, let’s run the pre-commit across all files: ... The code quality looks much better after running the Pre-commit linter. Here is an example:
🌐
Python-boilerplate
python-boilerplate.github.io › poetry-template › features › pre-commit
Pre-commit Hooks - python boilerplate
Edit the .pre-commit-config.yaml file and add the required hook. For example, to add Ruff:
🌐
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 - 20:47 So this next one is pretty interesting that we're adding here in this example, and that's the rough pre-commit from straight from Astral, right? 20:57 So this is just github.com/astral.sh, which is the company behind rough newbie.
🌐
Stefanie Molin
stefaniemolin.com › articles › devx › pre-commit › setup-guide
How to Set Up Pre-Commit Hooks | Stefanie Molin
December 7, 2025 - The pre-commit hooks that we will use in this tutorial run checks on configuration files (like YAML and TOML) and Python files. To make it easier to follow along, I have created a small GitHub template repository at stefmolin/pre-commit-example with a Python package skeleton for a dummy package called example, but you can also use a Python project of your own.
🌐
GitHub
github.com › marketplace › actions › pre-commit
pre-commit · Actions · GitHub Marketplace
name: pre-commit on: pull_request: push: branches: [main] jobs: pre-commit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v3 - uses: pre-commit/action@v3.0.1
🌐
GitHub
github.com › pre-commit › action
GitHub - pre-commit/action: a GitHub action to run `pre-commit` · GitHub
name: pre-commit on: pull_request: push: branches: [main] jobs: pre-commit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v3 - uses: pre-commit/action@v3.0.1
Starred by 550 users
Forked by 199 users
🌐
Data Science
diogoribeiro7.github.io › home › python › software development › version control
A Comprehensive Guide to Pre-Commit Tools in Python - Data Science
August 19, 2024 - Here’s an example of how to integrate pre-commit with GitHub Actions: Create a .github/workflows/pre-commit.yml file in your repository with the following content: name: pre-commit on: [push, pull_request] jobs: pre-commit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.x' - name: Install dependencies run: pip install pre-commit - name: Run pre-commit hooks run: pre-commit run --all-files
🌐
Y-sunflower
y-sunflower.github.io › python-packaging-essentials › blog › workflow › pre-commit.html
9 Pre-commit Hooks – Python Packaging Essentials
Now try editing a Python file (add spaces at the end of the file or change the formatting of something). Then try committing it: git add .pre-commit-config.yaml git commit -m "Test pre-commit"