预提交 InvalidConfigError

pre-commit InvalidConfigError

当我想在 .pre-commit-config.yaml 中提交更改时,出现以下错误:

An error has occurred: InvalidConfigError: 
==> File .pre-commit-config.yaml
=====> while parsing a block mapping
  in "<unicode string>", line 33, column 3
did not find expected key
  in "<unicode string>", line 34, column 3
Check the log at /Users/name/.cache/pre-commit/pre-commit.log

第 33 行以上是:

- repo: local
  - id: pytest
    name: Run tests (pytest)
    entry: pytest -x
    language: system
    types: [python]
    pass_filenames: false

我错过了向文件添加“钩子”,现在可以了:

- repo: local
  hooks:  # <- this was missing
  - id: pytest
    name: Run tests (pytest)
    entry: pytest -x
    language: system
    types: [python]
    pass_filenames: false