Skip to content

pre-commit: "Expected one of commit, commit-msg, manual, ..." since 23.11.0 #4065

@martin-thoma

Description

@martin-thoma

Describe the bug

When the pre-commit hook is installed and I commit, I get:

An error has occurred: InvalidManifestError: 
==> File /home/martin/.cache/pre-commit/repolc31_gpb/.pre-commit-hooks.yaml
==> At Hook(id='black')
==> At key: stages
==> At index 0
=====> Expected one of commit, commit-msg, manual, merge-commit, post-checkout, post-commit, post-merge, post-rewrite, prepare-commit-msg, push but got: 'pre-commit'

To Reproduce

$ python --version
3.11.1

$ python -m venv venv
$ source venv/bin/activate

$ vim .pre-commit-config.yaml
# Add this:
-   repo: https://github.com/psf/black
    rev: 23.11.0
    hooks:
    -   id: black  

$ echo "a = 'b'" > c.py

$ git init
$ git add .pre-commit-config.yaml c.py
$ pip install pre-commit
$ pre-commit install

$ pre-commit --version
pre-commit 3.5.0

$ git commit -m "Example"

The resulting error is:

An error has occurred: InvalidManifestError: 
==> File /home/martin/.cache/pre-commit/repolc31_gpb/.pre-commit-hooks.yaml
==> At Hook(id='black')
==> At key: stages
==> At index 0
=====> Expected one of commit, commit-msg, manual, merge-commit, post-checkout, post-commit, post-merge, post-rewrite, prepare-commit-msg, push but got: 'pre-commit'

Expected behavior

A pre-commit fixes c.py

Environment

  • Black's version: 23.11.0
  • OS and Python version: Linux / Python 3.11.1

Additional context

#3940

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions