pre-commit.com

What hook language should I use for pre-commit hooks written in Python?

What hook language should I use for pre-commit hooks written in Python? Question: I’m working on a local pre-commit hook written in Python. At first, I saw this quote from the pre-commit documentation: python The hook repository must be installable via pip install . (usually by either setup.py or pyproject.toml). I made the repo with …

Total answers: 1

Pre-commit install-hooks does not work (SSLError)

Pre-commit install-hooks does not work (SSLError) Question: 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’, port=443): Max retries exceeded w ith url: /simple/ruamel-yaml/ (Caused by SSLError("Can’t connect to HTTPS URL because the SSL …

Total answers: 1

pre-commit fails to install isort 5.11.4 with error "RuntimeError: The Poetry configuration is invalid"

pre-commit fails to install isort 5.11.4 with error "RuntimeError: The Poetry configuration is invalid" Question: pre-commit suddenly started to fail installing the isort hook in our builds today with the following error [INFO] Installing environment for https://github.com/pycqa/isort. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes… An unexpected error …

Total answers: 5

Pre-commit hook throws error on hatchling requirement

Pre-commit hook throws error on hatchling requirement Question: 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: https://github.com/pre-commit/pre-commit-hooks rev: v2.3.0 hooks: – id: check-yaml – id: end-of-file-fixer – id: …

Total answers: 2

How to raise flake8 error when found particular string in whole project.?

How to raise flake8 error when found particular string in whole project.? Question: When I run flake8 . command I want to raise flake8 error if "print_queries" string is present anywhere in project files checked into VCS (and not excluded). Here’s my flake8 configuration: [flake8] exclude = .venv, migrations, scaffoldapp max-line-length = 130 per-file-ignores = …

Total answers: 1

Access python interpreter in VSCode version controll when using pre-commit

Access python interpreter in VSCode version controll when using pre-commit Question: 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 error: …

Total answers: 2

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

running pre-commit python package in Windows gives ExecutableNotFoundError: Executable `/bin/sh` Question: 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: Executable `/bin/sh` not found Check …

Total answers: 1

How to have a single source of truth for poetry and pre-commit package version?

How to have a single source of truth for poetry and pre-commit package version? Question: I’m looking into this Python project template. They use poetry to define dev dependencies [tool.poetry.dev-dependencies] black = {version = "*", allow-prereleases = true} flake8 = "*" isort = "^5.6" mypy = ">0.900,<1" … They use also pre-commit to check housekeeping …

Total answers: 2

The hook `black` requires pre-commit version 2.9.2 but version 2.6.0 is installed

The hook `black` requires pre-commit version 2.9.2 but version 2.6.0 is installed Question: 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 install –upgrade …

Total answers: 2

Ignoring Django Migrations in pyproject.toml file for Black formatter

Ignoring Django Migrations in pyproject.toml file for Black formatter Question: I just got Black and Pre-Commit set up for my Django repository. I used the default config for Black from the tutorial I followed and it’s been working great, but I am having trouble excluding my migrations files from it. Here is the default configuration …

Total answers: 5