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
Here's an example of using check-json against non-json files: - id: check-json types: [file] # override `types: [json]` files: \.(json|myext)$ Files can also be matched by shebang. With types: python, an exe starting with #!/usr/bin/env python3 will also be matched.
GitHub
github.com › pre-commit › pre-commit-hooks
GitHub - pre-commit/pre-commit-hooks: Some out-of-the-box hooks for pre-commit · GitHub
As a result, it will ignore any setting of files, exclude, types or exclude_types. Set always_run: false to allow this hook to be skipped according to these file filters. Caveat: In this configuration, empty commits (git commit --allow-empty) would always be allowed by this hook. Checks that all your JSON files are pretty.
Starred by 6.5K users
Forked by 789 users
Languages Python
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 - validate json-like files - Stack Overflow
I would recommend adding a special hook and keeping the original one in place. using your example it would look something like this: repos: - repo: https://github.com/python-jsonschema/check-jsonschema rev: '0.27.3' hooks: - id: check-jsonschema # not necessary, but can be useful for `pre-commit ... More on stackoverflow.com
What are your pre-commit hooks?
Please read our latest update. https://www.reddit.com/r/ExperiencedDevs/comments/142pwq9/sub_blackout_and_new_platform/ I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
pre-commit vs pre-push vs CI/CD for linting and formatting?
I’d make it part of merge checks.
Can’t merge unless all the requirements are OK, if formatting/linting are requirements then it’s nice to see failed checks and know what requires fixing.
More on reddit.comVideos
15:16
Boost Your Coding Efficiency with Git Pre-Commit Hooks - YouTube
04:52
How to Run a Python Script Upon Commit Using a Pre-Commit Hook ...
14:38
Configuring Pre-Commit Hooks to Automate Python Testing and Linting ...
Increase Python code quality with pre-commit
19:18
How to use Git Hooks - YouTube
09:20
Python Pre-Commit Hooks Setup in a single video! - YouTube
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
Readthedocs
econ-project-templates.readthedocs.io › en › v0.5.2 › pre-commit.html
Pre-Commit Hooks — Tutorial: Templates for reproducible research projects
check-added-large-files: Checks that all committed files do not exceed 100MB in size. This is the maximal file size allowed by Github. check-byte-order-marker: Fails if file has a UTF-8 byte-order marker. check-json: Checks whether all files that end with .json are indeed valid json files. pyupgrade: Converts Python code to make use of newer syntax. pretty-format-json: Reformats your json files to be more readable.
PyPI
pypi.org › project › pre-commit-hooks
pre-commit-hooks · PyPI
As a result, it will ignore any ... file filters. Caveat: In this configuration, empty commits (git commit --allow-empty) would always be allowed by this hook. Checks that all your JSON files are pretty....
» pip install pre-commit-hooks
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.
GitHub
github.com › pre-commit › pre-commit-hooks › blob › main › .pre-commit-hooks.yaml
pre-commit-hooks/.pre-commit-hooks.yaml at main · pre-commit/pre-commit-hooks
types: [json] - id: check-shebang-scripts-are-executable · name: check that scripts with shebangs are executable · description: ensures that (non-binary) files with a shebang are executable. entry: check-shebang-scripts-are-executable · language: python · types: [text] stages: [pre-commit, pre-push, manual] minimum_pre_commit_version: 3.2.0 ·
Author pre-commit
Marcus Folkesson
marcusfolkesson.se › blog › pre-commit
Increase the quality of your commits with pre-commit | Marcus Folkesson Blog
March 29, 2024 - check-builtin-literals - requires literal syntax when initializing empty or zero python builtin types. check-case-conflict - checks for files that would conflict in case-insensitive filesystems. check-docstring-first - checks a common error of defining a docstring after code. check-executables-have-shebangs - ensures that (non-binary) executables have a shebang. check-json - checks json files for parseable syntax. check-shebang-scripts-are-executable - ensures that (non-binary) files with a shebang are executable. pretty-format-json - sets a standard for formatting json files.
Medium
medium.com › marvelous-mlops › welcome-to-pre-commit-heaven-5b622bb8ebce
Welcome to pre-commit heaven. Where I learned to stop worrying and… | by Raphaël Hoogvliets | Marvelous MLOps | Medium
June 28, 2023 - check-json: Validates JSON files for syntax errors. check-toml: Validates TOML files for syntax errors. check-yaml: Validates YAML files for syntax errors. check-shebang-scripts-are-executable: Verifies that shebang scripts (scripts starting with #!/) are executable. bandit: Checks for common security issues in Python code. repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: - id: check-ast - id: check-added-large-files - id: check-json - id: check-toml - id: check-yaml - id: check-shebang-scripts-are-executable - repo: https://github.com/PyCQA/bandit rev: 1.7.4 hooks: - id: bandit
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 - We have already seen an example of how to write a pre-commit hook configuration. Now, let's delve deeper into it. Firstly, let's take another look at the sample configuration. repos: - repo: https://github.com/PyCQA/flake8 rev: 3.9.2 hooks: - id: flake8 name: flake8 types: [python] args: - --max-line-length=88 - --ignore=E203,E501,W503
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:
Towards Data Science
towardsdatascience.com › home › latest › custom pre-commit hooks for safer code changes
Custom pre-commit hooks for safer code changes | Towards Data Science
January 22, 2025 - The preferred way of working with ... Python library. We can set it up with the following steps: Create a git repository for your project with git init · Install the pre-commit library with pip install pre-commit · Add a .pre-commit-config.yaml to your repository. Here’s an example...
Reddit
reddit.com › r/experienceddevs › what are your pre-commit hooks?
r/ExperiencedDevs on Reddit: What are your pre-commit hooks?
June 8, 2023 -
Hi folks!
I'm curious to know what pre-commit hooks you're using.
I start with linters and formatters.
Top answer 1 of 46
208
I've found precommit hooks to be pretty clunky. A precommit hook failing comes at an awkward time and interrupts my train of thought for making a commit. I've also found that managing the tools and config for them is pretty annoying, either manually or with pre-commit . Instead, I have my editor run formatters/linters/etc and add checks for them in CI. Format-on-save is just the way to go.
2 of 46
183
No pre commit hooks at all. Linting and formatting checks are in the CI, and all projects have a VSCode devcontainer with enabled auto formatting but we don’t have pre commit hooks.
Medium
gatlenculp.medium.com › effortless-code-quality-the-ultimate-pre-commit-hooks-guide-for-2025-57ca501d9835
Effortless Code Quality: The Ultimate Pre-Commit Hooks Guide for 2025
February 9, 2025 - This is a community supported pre-commit hook, endorsed by microsoft · Note: MyPy is the original type checker, but Pyright offers better speed and features. # STRICT - repo: <https://github.com/RobertCraigie/pyright-python> rev: v1.1.391 hooks: - id: pyright name: "🐍 python · Check types" validate-pyproject specifically handles pyproject.toml validation. In the future, I may have check-jsonschema do this as well.
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.
GitHooks
githooks.com
Learn how to improve your Git skills
Git Hooks are scripts that Git can execute automatically when certain events occur, such as before or after a commit, push, or merge. There are several types of Git Hooks, each with a specific purpose. Pre-commit hooks, for example, can be used to enforce code formatting or run tests before a commit is made.