python-3.x 幼雏要求的预提交挂钩投掷错误

inn6fuwd  于 2022-12-15  发布在  Python
关注(0)|答案(1)|浏览(118)

我在pre-commit directions后面安装git预提交钩子,用于python代码从black到我的flask repo的格式化。我已经添加了pre-commit到我的requirements.txt,我的pre-commit-config.yaml文件看起来像

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

在使用pip install pre-commit安装pre-commit并使用pre-commit install安装git hook脚本后,我在使用git commit提交git时收到了与hatchling依赖包相关的错误消息。

[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

有人见过这种情况并知道如何解决吗?

i2byvkas

i2byvkas1#

modern hatchling不支持python3.6-- pip无法找到一个与您的请求匹配的,因为3.6支持在0.25.1之后被丢弃
您可以通过language_version强制使用不同的语言版本(假设您安装了Python)--例如:

-   id: black
        language_version: python3.11

免责声明:我创建了预提交

相关问题