我在这里使用Python3.10.4,并在我的诗歌1.1.13项目中使用使用pyproject.toml的. project config.yaml文件。
以下是我的.config.yaml的样子
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
# https://stackoverflow.com/questions/64935598/git-pre-commit-get-all-python-files
default_language_version:
python: python3.10
default_stages: [commit, push]
repos:
- repo: local
hooks:
# https://github.com/pre-commit/pre-commit-hooks#check-ast
- id: check-ast
description: Simply checks whether the files parse as valid python.
entry: check-ast
name: Check python syntax
language: system
types: [python]
# https://github.com/pre-commit/pre-commit-hooks#check-added-large-files
- id: check-added-large-files
description: prevents giant files from being committed.
entry: check-added-large-files
name: Check added large files
language: system
# https://github.com/pre-commit/pre-commit-hooks#check-json
- id: check-json
description: Checks json files for parseable syntax.
entry: check-json
name: Check JSON
language: system
types: [json]
# https://github.com/pre-commit/pre-commit-hooks#check-toml
- id: check-toml
description: Checks toml files for parseable syntax.
entry: check-toml
name: Check TOML
language: system
types: [toml]
# https://github.com/pre-commit/pre-commit-hooks#check-yaml
- id: check-yaml
description: Checks yaml files for parseable syntax.
entry: check-yaml
name: Check YAML
language: system
types: [yaml]
# https://github.com/pre-commit/pre-commit-hooks#end-of-file-fixer
- id: end-of-file-fixer
description: Ensures that a file is either empty, or ends with one newline.
entry: end-of-file-fixer
name: End of file fixer
language: system
# https://github.com/pre-commit/pre-commit-hooks#trailing-whitespace
- id: trailing-whitespace
description: Trims trailing whitespace.
entry: trailing-whitespace-fixer
name: Trailing whitespace
language: system
- repo: local
hooks:
- args: ["--verbose"]
id: flake8
description: Command-line utility for enforcing style consistency across Python projects.
entry: flake8
name: flake8
language: python
require_serial: true
types: [python]
- args: ["--verbose"]
id: black
description: The uncompromising Python code formatter
entry: black
name: black
language: python
require_serial: true
types: [python]
- args: ["--verbose"]
id: isort
name: isort
entry: isort
require_serial: true
language: python
types: [python]
- args: ["--verbose"]
exclude: tests/.*$
id: bandit
name: bandit
entry: bandit
language: python
types: [python]
- args: ["--verbose"]
id: mypy
name: mypy
entry: mypy
language: python
require_serial: true
types: [python]当我运行git提交-m“测试”时,它会失败,并出现以下错误
Check python syntax......................................................Failed
- hook id: check-ast
- exit code: 1
Executable `check-ast` not found
Check added large files..................................................Failed
- hook id: check-added-large-files
- exit code: 1
Executable `check-added-large-files` not found
Check JSON...........................................(no files to check)Skipped
Check TOML...............................................................Failed
- hook id: check-toml
- exit code: 1
Executable `check-toml` not found
Check YAML...........................................(no files to check)Skipped
End of file fixer........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
Executable `end-of-file-fixer` not found
Trailing whitespace......................................................Failed
- hook id: trailing-whitespace
- exit code: 1
Executable `trailing-whitespace-fixer` not found
flake8...................................................................Failed
- hook id: flake8
- exit code: 1
Executable `flake8` not found
black....................................................................Failed
- hook id: black
- exit code: 1
Executable `black` not found
isort....................................................................Failed
- hook id: isort
- exit code: 1
Executable `isort` not found
bandit...................................................................Failed
- hook id: bandit
- exit code: 1
Executable `bandit` not found
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1
Executable `mypy` not found如何使预提交使用诗歌创建的虚拟环境并在本地使用其所有依赖项?
发布于 2022-07-06 18:14:51
使用预提交的方式是不推荐的,也不支持。预提交的重点是它安装和管理您的工具-这样您就不必让您的贡献者担心在所需的版本上安装每个工具。
尽管如此,您可以像使用language: system一样避开受支持的路径--但是您的贡献者需要在正确的版本和适当的virtualenv激活以及安装在虚拟环境中的适当版本(这很容易出错,而且通常是一种糟糕的体验)的情况下进行正确的设置。
你遇到问题的原因是因为你持有错误:)
免责声明:我创建了预提交。
https://stackoverflow.com/questions/72888074
复制相似问题