375 questions
0
votes
1
answer
201
views
Successful mypy run interpreted as failure in pre-commit
Given a .pre-commit-config.yaml:
repos:
- repo: local
hooks:
- id: mypy
name: mypy
language: system
entry: uv run mypy
types: [python]
require_serial: true
exclude: scripts/...
0
votes
1
answer
144
views
Execute another command in entry in pre-commit hook
I have to run command, which 1 argument requires output from another command (see below). Is there a way how to accomplish this? Either in entry or args? Or does pre-commit offer some built in feature ...
2
votes
1
answer
133
views
Pre-commit pointing to /snap/bin/pre-commit
I am working on new project and installed pre-commit using:
python -m pip install pre-commit
within my created environment (i.e. a python=3.9 env)
When I run pre-commit, I had an incompatibility ...
-2
votes
2
answers
1k
views
How prevent check-yaml for specific file or line inside that file with pre-commit and pre-commit-hooks?
I am trying to enable mermaid in mkdocs using the material theme.
According to the docs I should be able to enable it via:
markdown_extensions:
- pymdownx.extra:
pymdownx.superfences:
...
1
vote
1
answer
87
views
How do I escape spaces in arguments that are a part of a pre-commit hook’s entry value?
I’m currently working on a few repositories that contain Nix flakes. You can test a Nix flake by running this Bash command:
nix flake check
That command will only work if you have the nix-command and ...
-3
votes
1
answer
130
views
How to exclude a directory from google-java-format via Git pre-commit hook?
.pre-commit-hooks.yaml is like below:
- id: google-style-java
name: Google Java Code Style for Java
description: Formats code in Google's Java codestyle.
entry: ./format-code.sh
...
0
votes
1
answer
908
views
How to export dependencies to requirement.txt and requirements-dev.txt using uv-pre-commit
I'm using uv as my package manager in my Python project. My pyproject.toml file looks like this:
[project]
name = "some-name"
version = "0.1.0"
readme = "README.md"
...
0
votes
2
answers
97
views
Apply fixes only on the modified text
Is there a way to tell the pre-commit (pre-commit.com) to apply fixes just to the modified text instead of the entire files touched? We want to set up spellchecking (using typos) on our API models, ...
0
votes
1
answer
106
views
Checkov running on Swagger docs even though excluded
I have a pre-commit configuration that I use inside a Go repository. This repository includes Go files and Swagger docs generated by Protobuf so I want to exclude those from the checks to avoid issues ...
0
votes
1
answer
240
views
buf pre-commit expecting system-installed go but it is
I'm using some pre-commit hooks for Buf to help me check Protobuf files before compiling them to Go:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 # Use the ref you ...
0
votes
0
answers
61
views
Why do I need to specify some dependencies to pyright but not others? [duplicate]
I'm building a python app with a .toml file. I'm using poetry to deal with dependencies and packaging. Here is an extract of my toml file
[tool.poetry]
name = "app_name"
version = "0.1....
-1
votes
1
answer
111
views
Cloudformation linter regions unsupported
I'm setting up cfn-lint as a pre-commit hook using this guide: https://aws.amazon.com/blogs/mt/git-pre-commit-validation-of-aws-cloudformation-templates-with-cfn-lint/
My .pre-commit-config.yaml:
...
0
votes
1
answer
1k
views
Getting `An error has occurred: FatalError: git failed.` when running pre-commit in GitLab pipeline
I'm trying to run the pre-commit tool in a GitLab pipeline. I use a custom-built Python image that has git installed in the pipeline job. I install pre-commit at the start of the job using a pip ...
-1
votes
1
answer
399
views
pre-commit fails with ModuleNotFoundError: No module named 'yaml'
I am using pre-commit. In one of the hooks, I use a python script that imports the yaml library.
However, when I try to commit something, I get the following error on this hook :
ModuleNotFoundError: ...
1
vote
1
answer
229
views
Pre-commit finds local hooks even after deleting the hooks directory and clearing the cache
I am using pre-commit to manage local hooks for my repository. Initially, I added a local repository containing my hooks and configured the .pre-commit-config.yaml file to reference these hooks. It ...
1
vote
2
answers
2k
views
include a single pre-commit-config file in many repos
I'm starting to use pre-commit, and I have a single repository with a pre-commit-config.yaml file that I want all the other (many more) repositories to simply 'include'. Is there a way to do that?
The ...
0
votes
0
answers
241
views
Pre-commit hooks in R/RStudio. How do I change the max line length to 120?
From the precommit package (https://cran.r-project.org/web/packages/precommit/index.html), I'm taking the default pre-commit-config.yml file as my starting point. You can recreate it with precommit::...
4
votes
1
answer
2k
views
InvalidManifestError: At key language: Expected one of ... but got: 'python_venv'
I've been using pre-commit for quite a while successfully! recently I updated and I'm getting a new error message but it worked fine before
here is the error message:
$ pre-commit run --all-files
[...
0
votes
1
answer
1k
views
Error loading config: Requested templater 'dbt' which is not currently available. Try one of raw, jinja, python, placeholder
Need to understand that what is causing the issue in the pre-commit hook section of sqlfluff
Although sqlfluff-templater-dbt is installed sqlfluff is installed, but gets and error that templater 'dbt'...
0
votes
2
answers
905
views
using attrs pre-commit mypy error: Unexpected keyword argument
mypy runs perfectly on terminal, but when running on pre-commit stage, I am getting the error Unexpected keyword argument for every property in my class
from attrs import define, field
@define(
...
0
votes
1
answer
635
views
pre-commit using mypy specify venv cross-platform
I'm using pdm, and each project has its own .venv. When using mypy, I need to specify venv like mypy --python-executable ./.venv/Scripts/python.exe . on windows or mypy --python-executable ./.venv/bin/...
1
vote
1
answer
547
views
How to skip checking third-party dependencies when using clang-tidy?
I'm using clang-tidy in my C++ project, and I'm encountering errors related to third-party dependencies, specifically Abseil (absl). I want to skip checking these dependencies.
jiawei@DESKTOP-AEQS7B5:~...
0
votes
0
answers
60
views
Specify pre-commit cache directory on vscode to properly use source-control [duplicate]
I'm using pre-commit along with the source-control in vscode. I want to be able to specify the cache directory of pre-commit, so I defines the PRE_COMMIT_HOME environment variable in .bashrc. ...
1
vote
1
answer
642
views
pre-commit won't run stage commit-msg local hooks
I'm having great difficulty making something that seems simple and logical but doesn't work.
As part of a GitHub repository with Python code, I want to manage a pre-commit that will launch a python ...
1
vote
1
answer
1k
views
GitHub Actions PreCommit FatalError: git failed
I have a task to move CI/CD from Gitlab to GitHub Actions and there is one last obstacle I encounter. PreCommit library is not working.
Everything worked fine in gitlab and that is why I have no idea ...
2
votes
1
answer
1k
views
Prettier Plugins Not Found with Pre-Commit
I'm using Prettier with pre-commit to format my code before committing. However, I encountered an issue where Prettier doesn't seem to recognize the plugins.
With this setup, Prettier is not able to ...
8
votes
3
answers
1k
views
pre-commit Error missing config value GIT_CONFIG_VALUE_0
When i commit changes via Github Desktop, pre-commit cannot handle the changes and commit them but overwrites all other stages changes (the once i didn't intent to commit now) by its improvements.
...
0
votes
1
answer
510
views
commitizen - how to run commit check in gitlab ci
I'm using a commitizen and a pre-commit
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.27.0
hooks:
- id: commitizen
name: commit message check
On local everything is ...
2
votes
1
answer
1k
views
Different results between CLI and pre-commit
I've set up a pre-commit hook using Ruff to handle linting in my project. I've configured the hook as per the documentation:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.9
hooks:
...
0
votes
0
answers
148
views
pre-commit version did not match created version on msys2
I would like to install pre-commit on msys2, I ran pacman -S mingw-w64-x86_64-python-pre-commit successfuly but when I try to run it after pre-commit in a repo with hooks, I got the following error:
$ ...
1
vote
0
answers
2k
views
How do I set up pre-commit to use hooks from a private repository using a GIT_TOKEN?
I am trying to run pre-commit using hooks from a private repository using a GIT_TOKEN.
Before running pre-commit run --all-files, I insert my GIT_TOKEN (which has read access to the hooks repository) ...
1
vote
2
answers
1k
views
Executable not found while running custom pre-commit hook written in Go
I am trying to build a custom pre-commit hook written in Go. It should run on python file.
The project has the following architecture:
comche/
├── cmd/
│ └── main.go
├── scripts/
│ └── main -> ...
0
votes
1
answer
90
views
pre-commit: slither: error: unrecognized arguments: .env.example src/DecentralisedInvestmentManager.sol
While trying to make slither work with pre-commit, I noticed slither expects a single file, or directory as CLI args, whereas (my) pre-commit-config.yaml provides slither with a list of space ...
1
vote
1
answer
117
views
Understanding different ways to run SolHint 4.5.4 in pre-commit without errors
Context
I have tried 3 different approaches to running SolHint 4.5.4 using pre-commit.
Run with separate run_solhint.sh script, which works but I cannot get the bash syntax to work with .pre-commit ...
0
votes
1
answer
693
views
pre-commit with mirrors-mypy shows errors i already fixed
i cleaned cache with
pre-commit clean && pre-commit gc
but it still shows me errors i already fixed:
$ git commit -m "fake commit"
[WARNING] Unstaged files detected.
[INFO] Stashing ...
0
votes
1
answer
718
views
pre-commit autoupdate C:\Users\username\AppData\Local\Temp\tmp4up095pz\.pre-commit-hooks.yaml is not a file
Need some help desperately now:
I am creating a pre-commit hook to trigger dotnet format tool when git commit -m ""
And I have a p.re-commit-config.yaml file right inside the solution root ...
15
votes
1
answer
10k
views
How to clear the pre-commit caches?
The ~/.cache/pre-commit/ folder is many GB large, how do I clean it?
Can I simply delete it?
Or at least delete all the files?
Or do I have to be selective about it?
Is there a command for cleaning ...
0
votes
1
answer
822
views
Run pre-commit hook with `pass_filenames: true` only once with all filenames
I have a pre-commit hook running a local executable and I set the pass_filenames to true. When there are 11 files to modify in the git staging area, the hook is called three times with different ...
1
vote
2
answers
3k
views
pre-commit-config adding local dependencies
I'm setting up pre-commit hooks on my project and I'm working with self-developped packages that happen to be in root of the project and I can't seem to add them as additional_dependencies in my ...
1
vote
1
answer
2k
views
Pre-Commit MyPy unable to disable non-error messages
I'm putting together some pre-commit hooks for a project that I'm working on, and one of the hooks we want to use is MyPy. The pre-commit results are throwing up a lot of non-error notes related to ...
1
vote
3
answers
4k
views
Pre-commit hooks: Executable <hook_name> not found
I try to use pre-commit on VSCode.
I installed ruff, black, mypy and flake8 using poetry.
Pre-commit-config.yaml
default_language_version:
python: python3.10
repos:
- repo: local
hooks:
...
0
votes
1
answer
1k
views
just: error: Justfile does not contain recipes when pre-committing
I'm referencing just commands in custom pre-commit hooks. For some reason, just is interpreting staged files as recipes, which leads to
trim trailing whitespace............................................
-1
votes
1
answer
335
views
Why is pre-comit run --all-files -v is not checking Python files
This is my .pre-commit-config.yaml
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: fix-encoding-pragma
- id: check-ast
In same directotry ...
0
votes
1
answer
1k
views
ansible-lint during pre-commit in CI/CD
Locally run ansible-lint pre-commit behaves differently than run during CI/CD.
I use following
---
repos:
- repo: https://github.com/ansible/ansible-lint
rev: v24.2.1
hooks:
- id: ...
1
vote
1
answer
3k
views
Cannot find implementation or library stub for module named
I have mypy pre-commit hook
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
args:
- --config-file=./.styleconfigs/mypy.ini
...
1
vote
1
answer
2k
views
How to use a config from pyproject.toml inside pre-commit-config.yaml
I have a python repository which has a pyproject.toml and a pre-commit-config.yaml
The pyproject.toml looks something like this
[tool.poetry]
name = "projectname"
description = "My ...
0
votes
1
answer
551
views
Kubeconform helm pre-commit plugin is skipping files
I have a helms folder structure and am trying to run the kubeconform pre-commit hook to test my yaml files. However, I everytime I run it, the files just get skipped.
Project
├── Makefile
├── helms
│ ...
1
vote
1
answer
2k
views
pre-commit - validate json-like files
in our project we add a big number of json-like files, which have a json structure, but are named with .meta extension (not a .json). We would like to validate the files against the json-schema before ...
1
vote
1
answer
910
views
Bump2version + pre-commit hook in python code
I'm using bump2version python module to increment my python codebase version automatically. When the pre-commit hook runs after the commit, the version.sh goes into indefinite loop and version keeps ...
1
vote
2
answers
1k
views
git pre-commit hook isort and black keep failing for a python project
I have a project using dash to commit, but it fails when I try to commit the following part:
@app_dash.callback(
Output("output_data_upload", "figure"),
[Input("...