For questions regarding the pre-commit framework, not to be confused with git pre-commit hooks generally. Use this tag only when your question involves the framework. The tool pre-commit is a framework for managing and maintaining multi-language pre-commit hooks.
Questions tagged [pre-commit.com]
309 questions
8
votes
3 answers
Pylint and pre-commit python 3.7
I am trying to set up pylint to work with pre-commit. I have looked into the docs, but still I am confused. I do not know how to setup .pre-commit-config.yaml properly.
Could you provide the most basic possible template?
- repo: myrepo
rev: ''…

maslak
- 1,115
- 3
- 8
- 22
7
votes
2 answers
Mypy can't find python-dateutil even after importing types-python-dateutil
I am running Mypy v0.910 with pre-commit. It complains that python-dateutil does not have type stubs. However, even after installing the stubs, I get the same error.
My pre-commit config is
default_language_version:
python: python3
repos:
…

Troy Daniels
- 3,270
- 2
- 25
- 57
7
votes
1 answer
How do I stop pre-commit on failure?
I have two git pre-commit hooks enabled in pre-commit-config.yml:
A code formatting hook that takes very little time
Our pytest hook, which takes much more time
When (1) updates code formatting, it fails, but (2) still runs. Then (1) and (2) must…

Mark C.
- 1,773
- 2
- 16
- 26
7
votes
3 answers
Cowardly refusing to install hooks with `core.hooksPath` set
i tried to run this command but it always show this error, i can't fix it with anyway. Help me, please!
(venv)<...>pre-commit install
[ERROR] Cowardly refusing to install hooks with core.hooksPath set.
hint: git config --unset-all core.hooksPath

Hữu Tuân
- 81
- 1
- 3
7
votes
2 answers
The hook `black` requires pre-commit version 2.9.2 but version 2.6.0 is installed
I am having trouble with pre-commit and black.
Everything worked fine until I cleared the cache with pre-commit clean. Now I always get the error
The hook black requires pre-commit version 2.9.2 but version 2.6.0 is installed. Perhaps run `pip…

shadow
- 151
- 2
- 12
7
votes
1 answer
pre-commit hook to check django migrations
I'm trying to write a pre-commit hook to my Django project that checks for missing migrations. That is, it ensures all changes are reflected in a migrations file.
One way to implement this is to PASS the pre-commit hook if the makemigrations command…

Johnny Metz
- 5,977
- 18
- 82
- 146
7
votes
1 answer
How can I configure pre-commit tool to rely on a single location for all hook configurations?
Please note that this question is about pre-commit.com tool and not about installing git-hooks.
The tool uses a .pre-commit-config.yml in the root of your repository, one file that defines which hooks are to be used and that also pins them using git…

sorin
- 161,544
- 178
- 535
- 806
6
votes
2 answers
How to configure pre-commit-config.yaml to work with poetry?
I am on Python 3.10.4 here and using a .pre-commit-config.yaml file in my Poetry 1.1.13 project that uses pyproject.toml
Here is what my .pre-commit-config.yaml looks like
# See https://pre-commit.com for more information
# See…

PirateApp
- 5,433
- 4
- 57
- 90
6
votes
2 answers
Access python interpreter in VSCode version controll when using pre-commit
I'm using pre-commit for most of my Python projects, and in many of them, I need to use pylint as a local repo. When I want to commit, I always have to activate python venv and then commit; otherwise, I'll get the following…

Mehdi
- 1,260
- 2
- 16
- 36
6
votes
2 answers
pre-commit giving error with mirrors-mypy, how do I fix it?
I am getting the below error when running "pre-commit run --all-files" and when trying to make a commit, it is some python error, python version in use is "Python 2.7.16".
[INFO] Installing environment for…

Paryush Kale
- 73
- 1
- 4
6
votes
2 answers
How to pre-install pre commit into hooks into docker
As I understand the documentation, whenever I add these lines to the config:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
hooks:
- id: trailing-whitespace
it makes pre-commit to download the hooks code…

ivaigult
- 6,198
- 5
- 38
- 66
6
votes
3 answers
env: python3.9: No such file or directory
I have some python code formatters as git pre-commit hook and I have changed my python version as
brew list | grep python
python@3.7
python@3.9
brew unlink python@3.7
brew unlink python@3.9
brew link python@3.7
python -V
Python 3.7.9
and know…

mrgloom
- 20,061
- 36
- 171
- 301
6
votes
1 answer
pre-commit.com: Same version in .pre-commit-config.yaml and requirements.txt
I would like to use the exactly same version of flake8 in requirements.txt and in .pre-commit-config.yaml.
To avoid redundancy I would like to keep the version number of flake8 exactly once in my repo.
Can pre-commit.com read the version number of…

guettli
- 25,042
- 81
- 346
- 663
6
votes
2 answers
pre-commit: How to disable the check for unstaged files?
My pre-commit.com config looks like this:
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:…

guettli
- 25,042
- 81
- 346
- 663
6
votes
1 answer
CalledProcessError with git pre-commit hook
I'm hitting a snag installing pre-commit hooks. Based on the error below, the hook installation cannot find a python exe in the directory C:\\Users\\dangler\\.cache\\pre-commit\\repoith5dg7x\\py_env-default\\Scripts\\python.EXE (python.EXE doesn't…

Danlger
- 143
- 1
- 1
- 7