Pir*_*App 6 pre-commit python-poetry pre-commit.com
我在这里使用 Python 3.10.4,并在使用 pyproject.toml 的 Poetry 1.1.13 项目中使用 .pre-commit-config.yaml 文件
这是我的 .pre-commit-config.yaml 的样子
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
# /sf/ask/4545491891/
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]
Run Code Online (Sandbox Code Playgroud)
当我运行 git commit -m "test" 时,它失败并出现以下错误
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
Run Code Online (Sandbox Code Playgroud)
如何预提交使用诗歌创建的虚拟环境并在本地使用其所有依赖项?
Ant*_*ile 15
不建议也不支持以您正在寻找的方式使用预提交。预提交的重点是它安装和管理您的工具——这样您就不必让您的贡献者担心安装所需版本的每个工具。
也就是说,您可以像您正在做的那样转义受支持的路径language: system- 但随后您的贡献者就需要在正确的版本上正确设置内容,并激活正确的 virtualenv 并在 virtualenv 中安装正确的版本(这很容易出错,而且通常是一种糟糕的体验)。
你遇到问题的原因是因为你的看法是错误的:)
免责声明:我创建了预提交
| 归档时间: |
|
| 查看次数: |
9551 次 |
| 最近记录: |