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
2
votes
2 answers
typescript-eslint/pre-commit hook (monorepo): Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser
We recently migrated to a monorepo and we are still trying to set everything up. We use typescript and eslint with prettier. The structure is the following:
root
- common
- folder_a
- file_a.ts
- build_scripts
- script_a.js
-…

XeniaSis
- 2,192
- 5
- 24
- 39
2
votes
2 answers
pre-commit yapf fails on file included in yapfignore
One of the pre-commit hooks set up in the repo is yapf (.pre-commit-config.yaml):
repos:
# Note: the YAPF config is found in `.style.yapf` and `.yapfignore`
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.29.0
hooks:
- id:…

MauroNeira
- 315
- 3
- 13
2
votes
0 answers
How to run mypy having local stubs directory at pre-commit?
I have separate directory for local stubs named stubs and at configuration file, I have set mypy_path=stubs.
When I run from command line mypy, it passes successfuly.
But at pre-commit it is throwing error.
pyproject.toml
[tool.mypy]
python_version…

Hasan
- 878
- 1
- 8
- 19
2
votes
1 answer
How to exclude untracked / new files from pre-commit hook via pre-commit.com?
We are using the pre-commit.com framework for configuring pre-commit hooks for our python project. When staging a set of files for commit, the pre-commit hooks should be applied on the state of the repo, where these staged files are…

eL_BaRTo
- 82
- 1
- 5
2
votes
2 answers
Pre-commit error: cannot spawn .git/hooks/pre-commit: No such file or directory
I think this is a Windows/WSL/Linux issue. anyone able to assist as when i install pre-commit and try to commit i get the error:
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -
error: cannot spawn…

Staggerlee011
- 847
- 2
- 13
- 23
2
votes
1 answer
Pre commit hook for eslint and vue
I am using pre-commit for several hooks within a multi language project. All my existing hooks are working. I am now trying to get a eslint hook setup that will include Vue 2 files.
Here's my .pre-commit-config.yaml for the eslint section:
- repo:…

darkpool
- 13,822
- 16
- 54
- 89
2
votes
0 answers
VSCode Restage Staged Files After Precommit Hooks Fail in order to Commit Again
I have a Django project with several pre-commit hooks with Python's pre-commit tool, configured as below:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
hooks:
- id: trailing-whitespace
- id:…

Eray Erdin
- 2,633
- 1
- 32
- 66
2
votes
1 answer
How to filter directories using the match-dir flag for pydocstyle?
I would like to use pydocstyle as a pre-commit hook to check a project's source code docstrings, i.e. .py files located inside the /src folder, when a new git commit is made. To check only the src folder, I used the match-dir option, however, it…

consoledotlog
- 124
- 1
- 9
2
votes
1 answer
when use pre-commit, mypy check passed but print mypy syntax error
I use pre-commit to run mypy type check, and when mypy check passed it print string error logs like this.
/username/.cache/pre-commit/repo61b8m7wl/py_env-python3.9/lib/python3.9/site-packages/mypy/typeshed/stdlib/2and3/builtins.pyi:33: error: syntax…
user11896097
2
votes
2 answers
Git commit gets permission denied but works with --no-verify
When I run, git commit -m 'Test' am getting this message:
[INFO] Initializing environment for git@github.com:humitos/mirrors-autoflake.git.
An unexpected error has occurred: CalledProcessError: command: ('/usr/local/git/libexec/git-core/git',…

konkani
- 488
- 1
- 7
- 15
2
votes
1 answer
How to run pre-commit on separate folders?
I use pre-commit, and I have a repository with two folders:
.
├── backend
│ └── (backend files)
├── frontend
│ └── (frontend files)
└── .pre-commit-config.yaml
Each folder has a Dockerfile and is independent from the other.
This is my…

lewislbr
- 1,012
- 14
- 23
2
votes
3 answers
Pre-commit-hook for Python project
How do I remove print statements in a Python project using pre-commit hook before checking in code to GitHub? Currently, I use black and flake8 pre-commit hooks. But they don't seem to have the option to check and remove print statements before…

akl
- 77
- 3
- 9
2
votes
1 answer
Windows python pre-commit getting ImportError sqlite
I'm trying to set up a pre-commit hook. To this end, I've created a .pre-commit-config.yaml like this:
repos:
- repo: https://github.com/ambv/black
rev: 19.10b0
hooks:
- id: black
language_version: python3.7
- repo:…

ma0ho
- 623
- 1
- 4
- 17
2
votes
2 answers
Pylint setup with pre-commit In python 3.5
I was trying to set up pylint with pre-commit in my project.
I came to this answer where they tell how to set up my .pre-commit-config.yaml.
When I went to the repository mentioned in the answer, they had written that
This mirror repository is…

saadi
- 646
- 6
- 29
2
votes
1 answer
isort a python directory manually and then can't push to remote repository
I am trying to add isort, black and flake8 into my project's pre-commit hooks, it works fine when I edit one single file.
What I want to achieve is isort one directory of the project by isort -rc . and push the changes to remote repository but it…

Haifeng Zhang
- 30,077
- 19
- 81
- 125