首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何配置预提交-config.yaml来处理诗歌?

如何配置预提交-config.yaml来处理诗歌?
EN

Stack Overflow用户
提问于 2022-07-06 18:02:58
回答 1查看 2.2K关注 0票数 1

我在这里使用Python3.10.4,并在我的诗歌1.1.13项目中使用使用pyproject.toml的. project config.yaml文件。

以下是我的.config.yaml的样子

代码语言:javascript
复制
# 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“测试”时,它会失败,并出现以下错误

代码语言:javascript
复制
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

如何使预提交使用诗歌创建的虚拟环境并在本地使用其所有依赖项?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-06 18:14:51

使用预提交的方式是不推荐的,也不支持。预提交的重点是它安装和管理您的工具-这样您就不必让您的贡献者担心在所需的版本上安装每个工具。

尽管如此,您可以像使用language: system一样避开受支持的路径--但是您的贡献者需要在正确的版本和适当的virtualenv激活以及安装在虚拟环境中的适当版本(这很容易出错,而且通常是一种糟糕的体验)的情况下进行正确的设置。

你遇到问题的原因是因为你持有错误:)

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

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72888074

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档