Search code examples
pre-commit-hookpre-commitpre-commit.com

pre-commit InvalidConfigError


When I want to commit my changes in the .pre-commit-config.yaml, I get the following error:

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

The lines 33+ are:

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

Solution

  • I missed adding "hooks" to the file, now it works:

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