预提交无法安装 isort 5.10.1,并出现错误“RuntimeError:Poetry 配置无效”

LOT*_*EAT 18 python pre-commit pre-commit-hook isort pre-commit.com

[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 has occurred: CalledProcessError: command: ('/builds/.../.cache/pre-commit/repo0_h0f938/py_env-python3.8/bin/python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
[...]
stderr:
      ERROR: Command errored out with exit status 1:
[...]
        File "/tmp/pip-build-env-_3j1398p/overlay/lib/python3.8/site-packages/poetry/core/masonry/api.py", line 40, in prepare_metadata_for_build_wheel
          poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False)
        File "/tmp/pip-build-env-_3j1398p/overlay/lib/python3.8/site-packages/poetry/core/factory.py", line 57, in create_poetry
          raise RuntimeError("The Poetry configuration is invalid:\n" + message)
      RuntimeError: The Poetry configuration is invalid:
        - [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$'
Run Code Online (Sandbox Code Playgroud)

我知道我可以将挂钩升级到 isort-5.12.0 来解决该问题。但是,我们的项目使用的是python-3.7,isort-5.12.0不支持它。考虑到兼容性,我们暂时不想更新python。我应该怎么办?

小智 12

这不是预提交问题,而是 Isort 问题。升级到最新版本的isort。现在已修复:

https://github.com/PyCQA/isort/issues/2077 https://github.com/PyCQA/isort/pull/2078