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: trailing-whitespace - repo: https://github.com/psf/black rev: 22.12.0 hooks: - id: black
After installing pre-commit
using pip install pre-commit
and installing the git hook scripts using pre-commit install
, I get this error message related to a hatchling
dependency package when making a git commit using git commit
.
[INFO] Installing environment for https://github.com/psf/black. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... An unexpected error has occurred: CalledProcessError: command: ('/Users/vcui/.cache/pre-commit/repoq7qnm1w0/py_env-python3.6/bin/python', '-mpip', 'install', '.') return code: 1 expected return code: 0 stdout: Processing /Users/vcui/.cache/pre-commit/repoq7qnm1w0 Installing build dependencies: started Installing build dependencies: finished with status 'error' stderr: ERROR: Command errored out with exit status 1: command: /Users/vcui/.cache/pre-commit/repoq7qnm1w0/py_env-python3.6/bin/python /Users/vcui/.cache/pre-commit/repoq7qnm1w0/py_env-python3.6/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/9r/jcsx6jv923lb_fmm4w09zq5m0000gp/T/pip-build-env-wtkwct01/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'hatchling>=1.8.0' hatch-vcs hatch-fancy-pypi-readme cwd: None Complete output (2 lines): ERROR: Could not find a version that satisfies the requirement hatchling>=1.8.0 (from versions: 0.8.0, 0.8.1, 0.8.2, 0.9.0, 0.10.0, 0.11.0, 0.11.1, 0.11.2, 0.11.3, 0.12.0, 0.13.0, 0.14.0, 0.15.0, 0.16.0, 0.17.0, 0.18.0, 0.19.0, 0.20.0, 0.20.1, 0.21.0, 0.21.1, 0.22.0, 0.23.0, 0.24.0, 0.25.0, 0.25.1) ERROR: No matching distribution found for hatchling>=1.8.0
Has anyone seen this before and know how to fix it?
Advertisement
Answer
modern hatchling does not support python3.6
— pip is unable to find one which matches your request because 3.6 support was dropped after 0.25.1
you can force a different language version (assuming you have that python installed) via language_version
— such as:
- id: black language_version: python3.11
disclaimer: I created pre-commit