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
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 - 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
🌐 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
🌐 r/ExperiencedDevs
118
87
June 8, 2023
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.com
🌐 r/devops
45
80
November 6, 2022
🌐
Python for Data Science
python4data.science › en › latest › productive › git › advanced › hooks › pre-commit.html
pre-commit framework - Python for Data Science
1 week ago - repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: … - id: check-json types: [file] files: \.(json|ipynb)$
🌐
Python for Data Science
python4data.science › en › 24.3.0 › productive › git › advanced › hooks › pre-commit.html
pre-commit framework - Python for Data Science 24.3.0
repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.2.0 hooks: … - id: check-json types: [file] files: \.(json|ipynb)$
🌐
Readthedocs
econ-project-templates.readthedocs.io › en › v0.4.5 › 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.
Find elsewhere
🌐
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
    
Published   Aug 09, 2025
Version   6.0.0
🌐
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
🌐
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.
🌐
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:
🌐
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.
🌐
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...
🌐
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.
🌐
Interrupt
interrupt.memfault.com › blog › pre-commit
Automatically format and lint code with pre-commit | Interrupt
October 27, 2021 - I find it does a nice job on Markdown, Javascript, JSON, and YAML files in particular. Installing prettier can be a bit of a pain if you don’t have node etc already available; pre-commit manages the tool itself here, which is ✨ amazing ✨! ruff - a Python linter that can catch a lot of ...