Questions tagged [pre-commit.com]

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.

309 questions
1
vote
1 answer

Can't commit - ImportError: cannot import name '_unicodefun' from 'click'

I'm trying to commit my files using using this process: git add git commit -m "Changes made to this commit" When I try to commit, I receive the following…
Daniel Johnson
  • 193
  • 2
  • 14
1
vote
2 answers

Why does pdoc in pre-commit pass locally, but fail with "files were modified by this hook" in GitHub action?

Pdoc is invoked last in my pre-commit hook, it builds documentation to /docs, which is included in my repository. Files in /docs are excluded from the pre-commit hook, so the formatting hooks don't touch them. I observe the following pattern: I run…
jobrachem
  • 105
  • 7
1
vote
2 answers

Exclude auto-generated files by Django within pre-commit-config.yaml using REGEX

Since the auto-generated Django files don't fulfill numerous pylint-requirements, my pre-commit checker fails: The files look usually like so: They seem to be located automatically in a sub-folder called "migrations": Now, I tried to leverage the…
Andreas L.
  • 3,239
  • 5
  • 26
  • 65
1
vote
2 answers

How to use a local flake8 plugin with a python virtual env?

I'm trying to integrate a project with a flake8 plugin I wrote as a local plugin (not a PyPI package for example) as explained here. The project uses a virtual env, both locally and as a github workflow. Since flake8 is invoked from within the…
Peleg
  • 1,025
  • 1
  • 7
  • 11
1
vote
2 answers

RuntimeError: failed to find interpreter for Builtin discover of python_spec='python3.1'

Description. While trying to use pre-commit hooks, I am experiencing some difficulties, including the latest Lava-nc release by Intel in .tar.gz format pip package in a Conda environment. MWE The following Conda environment.yaml file is used: # This…
a.t.
  • 2,002
  • 3
  • 26
  • 66
1
vote
1 answer

Excluding pytest files/marks from pre-commit hooks

Is there a way to exclude pytests marked with pytest.mark from running during the pre-commit hook? Especially, I'd like to exclude the tests that are marked as integration tests. The content of a tests looks like this pytestmark =…
wueli
  • 951
  • 11
  • 19
1
vote
2 answers

how to use pre-commit hook to sort a csv file

I have a .csv file that I'd like to sort pre-commit. I found this pre-commit hook file-contents-sorter which sorts the file with the first value. repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v2.1.0 hooks: - id:…
abidishajia
  • 222
  • 1
  • 6
  • 15
1
vote
1 answer

running pre-commit python package in Windows gives ExecutableNotFoundError: Executable `/bin/sh`

I am working on a project where pre-commit==2.15.0 was added to the python requirements file. I installed the requirements. Now when I try to do a git commit I get the following error: An unexpected error has occurred: ExecutableNotFoundError:…
afriedman111
  • 1,925
  • 4
  • 25
  • 42
1
vote
0 answers

Django-stubs doesn't ignore import

I've tried to configurate pre-commit + mypy + django-stubs, so I have error when i try to commit. ModuleNotFoundError: No module named 'environ' My configs: .pre-commit-config.yaml - repo: https://github.com/pre-commit/mirrors-mypy rev: '' …
1
vote
1 answer

How to return status `Skipped` in self defined pre-commit hook?

I have a self defined pre-commit hook which I want to skip if an earlier hook fails. If an earlier hook fails, a logfile named pre-commit.log is generated. A .pre-commit-config.yaml could look like this: repos: - repo:…
mosc9575
  • 5,618
  • 2
  • 9
  • 32
1
vote
0 answers

Correctly using pre-commit with flake8 plugins

So far, I have used tools from the local repo, where everything was run as a system command in the development environment. This works great, but is a bit on the slower side from the overhead of running things through poetry, and prevents running…
Numerlor
  • 799
  • 1
  • 3
  • 16
1
vote
1 answer

Install pre-commit on package install in setup.py file

I would like, when I install my python package with pip install ., that the command pre-commit install be run as well as everything else in the setup file. Here is my setup.py file where I try to execute this: from distutils.core import setup from…
Katya Willard
  • 2,152
  • 4
  • 22
  • 43
1
vote
1 answer

Exclude Test files from precommit hook

Use case- Exclude all test files from flake8. In my project I have test files in different folders. Current implementation: - repo: https://gitlab.com/PyCQA/flake8 rev: 4.0.1 hooks: - id: flake8 exclude: ^tests Current…
Isha Nema
  • 289
  • 5
  • 16
1
vote
1 answer

How to display scores for meeting --fail-under requirement .py files in .py lint, while using pre-commit?

My current pylint configuration: Installed via pip (in requirements.txt). The .pre-commit-config.yaml: - repo: local hooks: name: pylint entry: pylint language: system types: [ python ] files: ^src/ …
F1sher
  • 7,140
  • 11
  • 48
  • 85
1
vote
2 answers

Creating git-hooks for pre-commit using ggshield

I have a android project and want to install a pre-commit. I was following this example: https://docs.gitguardian.com/internal-repositories-monitoring/integrations/git_hooks/pre_commit repos: - repo: https://github.com/gitguardian/ggshield …
ant2009
  • 27,094
  • 154
  • 411
  • 609