pythonpre-commitpre-commit.compython-black

How to fix InvalidManifestError for pre-commit with black?


Running python pre-commit with black latest version 23.11.0 leads to a wired InvalidManifestError.

snippet from .pre-commit-config.yaml

repos:
-   repo: https://github.com/psf/black
    rev: 23.11.0
    hooks:
    -   id: black
        types: []
        files: ^.*.pyi?$  # format .py and .pyi files`

output message:

│ │      stdout = 'An error has occurred: InvalidManifestError: \n==> File                       │ │
│ │               /Users/robot/.cache/pre-c'+329                                                 │ │
│ │ stdout_list = [                                                                              │ │
│ │               │   'An error has occurred: InvalidManifestError: \n',                         │ │
│ │               │   '==> File                                                                  │ │
│ │               /Users/robot/.cache/pre-commit/repoxhmwyits/.pre-commit-hooks.yaml\n',         │ │
│ │               │   "==> At Hook(id='black')\n",                                               │ │
│ │               │   '==> At key: stages\n',                                                    │ │
│ │               │   '==> At index 0\n',                                                        │ │
│ │               │   '=====> Expected one of commit, commit-msg, manual, merge-commit,          │ │
│ │               post-checkout, '+86,                                                           │ │
│ │               │   'Check the log at /Users/robot/.cache/pre-commit/pre-commit.log\n'         │ │
│ │               ]           

Solution

  • you're using an outdated version of pre-commit. you need to be using at least version 3.2.0 which introduced the renamed stages


    disclaimer: I wrote pre-commit