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
0
votes
1 answer
How do I make sure that “pre-commit autoupdate” gets run periodically?
I know that I should check for pre-commit hook updates from time to time, but I rarely think about running pre-commit autoupdate. I end up using out-of-date pre-commit hooks for months.
pre-commit.ci will automatically run pre-commit autoupdate and…

Ginger Jesus
- 95
- 1
- 2
- 13
0
votes
0 answers
How to specify path to a local reposiory in .pre-commit-config.yaml?
I have a local package B which depends on another local package A. They both are stored in a company repository: https://mycompany.com/api/pypi/pypi-bld/simple. Therefore, tests of B requires A.
I need to use pre-commit which uses both the company…

Eugene W.
- 357
- 3
- 11
0
votes
1 answer
How can I enforce black's `--preview` option when invoking black with pre-commit?
I just found out that black's default behavior for long logfile messages does not enforce a maximum line length. I have verified that I can enforce max line length if I invoke black manually (v 23.1.0, in a Python 3.9.9 venv). Now I'd like to make…

Jeff Wright
- 1,014
- 1
- 11
- 17
0
votes
1 answer
pre-commit only seems to indicate the files to modify
if I use pre-commit I can see the files that should be modified, but they are not modified.
More exactly:
$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
$ pre-commit run --all-files
check for added large…

servoz
- 606
- 9
- 22
0
votes
0 answers
yamlfix not picking up updates to pyproject.toml
So the yamlfix docs say you can configure through pyproject.toml
https://lyz-code.github.io/yamlfix/#auto-configure-through-pyprojecttoml
But I can't find a way to make yamlfix, and pre-commit that is calling yamlfix, to pick up the changes. running…

sam
- 653
- 9
- 21
0
votes
1 answer
Github Desktop not honouring pylint installed in a .venv
I have a python project running in a virtual environment (created by poetry).
pylint is installed only in the virtual environment, not in the base.
pylint works well in the venv from command line, via pre-commit and inside Visual Studio Code which I…

Robert Alexander
- 875
- 9
- 24
0
votes
0 answers
What is the difference between creating tox environment for linting and using pre-commit hooks
I am learning CI/CD for Python packages and have worked through the text and examples in Dane Hillards's new Book Publishing Python Packages. I know there are a lot of different tools and approaches, but I am new to this and have a novice…

a11
- 3,122
- 4
- 27
- 66
0
votes
0 answers
Is there any way to ignore "Failed" state of the hook using pre-commit?
Let's say I have such config for pre-commit:
repos:
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
entry: isort .
always_run: true
pass_filenames: false
…

eawer
- 1,398
- 3
- 13
- 25
0
votes
2 answers
Pre-commit install-hooks does not work (SSLError)
I use conda Python environments. Whenever I try to run pre-commit install-hooks, I get the error
Could not fetch URL https://pypi.org/simple/ruamel-yaml/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org',…

karu
- 465
- 3
- 12
0
votes
4 answers
importlib.metadata error on pre-commit tool
I have installed pre-commit 3.0.1 via asdf. When I try to run pre-commit -v throwing the following error
Traceback (most recent call last):
File "/Users/san/.cache/pre-commit-zipapp/6Bkef3U7os33XPapd4VZ7HEfyUexbeBTjOn51afz0r8/python", line 47, in…

SANN3
- 9,459
- 6
- 61
- 97
0
votes
1 answer
pre-commit: Differentiating between files modified and actual failure
It seems pre-commit exits with code 0 if everything is fine, and exit code 1 if any checks Fail - regardless of reason.
Is there a way (programmatically) to differentiate between failures that resulted in files being modified (thereby fixing the…

odigity
- 7,568
- 4
- 37
- 51
0
votes
2 answers
How to activate Python env in the local directory and run pdoc with pre-commit?
I have recently created a GitHub Actions workflow to lint/reformat the code of my repo and create documentation HTML pages using pdoc. The last step is problematic, because pdoc runs the .py files to create the documentation. For one of the files…

jordp1
- 1
- 3
0
votes
0 answers
Tox and pre-commit hook "error: unrecognized arguments" or not running test envs
Everything is inside a docker container.
Tox works fine separately inside docker. What I'm trying to do is to add Tox to the pre-commit hook to run it for files with changes to be committed.
.pre-commit-config.yaml
- repo: local
hooks:
- …

QbS
- 425
- 1
- 4
- 17
0
votes
1 answer
Run different pre-commit hooks on different lists of files
I am trying to progressively add linting and automatic code formatting to a legacy codebase.
For now, I am just running all the hooks on the same list of "cleaned" files.
This is my .pre-commit-config.yaml file:
files: |
(?x)^(
…

PiRK
- 893
- 3
- 9
- 24
0
votes
1 answer
Pre-commit hook throws error on hatchling requirement
I'm following the pre-commit directions to install git pre-commit hooks for python code formatting from black to my flask repo. I've added pre-commit to my requirements.txt and my pre-commit-config.yaml file looks like
repos:
- repo:…

Victor Cui
- 1,393
- 2
- 15
- 35