Skip to content

error: Failed to parse .pre-commit-config.yaml #1111

@hugovk

Description

@hugovk

Summary

With pip's https://github.com/pypa/pip/blob/faedf9c63756f9ef9207f524c5835bc166a304f1/.pre-commit-config.yaml

https://www.yamllint.com/ says the YAML file is valid.

pre-commit --version
pre-commit 4.4.0pre-commit run --all-files
check builtin type constructor use.......................................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check toml...............................................................Passed
check yaml...............................................................Passed
debug statements (python)................................................Passed
fix end of files.........................................................Passed
forbid new submodules................................(no files to check)Skipped
trim trailing whitespace.................................................Passed
black....................................................................Passed
ruff check...............................................................Passed
mypy.....................................................................Passed
use logger.warning(......................................................Passed
check for eval().........................................................Passed
rst ``code`` is two backticks............................................Passed
codespell................................................................Passed
NEWS fragment........................................(no files to check)Skipped

Fails with prek 0.2.15 and 0.2.16:

prek --version
prek 0.2.15 (11f369ed7 2025-11-17)prek run --all-files
error: Failed to parse `.pre-commit-config.yaml`
  caused by: invalid indentation at line 45, column 5

Works with prek 0.2.14:

prek --version
prek 0.2.14 (30355ea9b 2025-11-14)prek run --all-files
Found existing alias for "prek run --all-files". You should use: "pkr"
check builtin type constructor use.......................................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check toml...............................................................Passed
check yaml...............................................................Passed
debug statements (python)................................................Passed
fix end of files.........................................................Passed
forbid new submodules................................(no files to check)Skipped
trim trailing whitespace.................................................Passed
black....................................................................Passed
ruff check...............................................................Passed
mypy.....................................................................Passed
use logger.warning(......................................................Passed
check for eval().........................................................Passed
rst ``code`` is two backticks............................................Passed
codespell................................................................Passed
NEWS fragment........................................(no files to check)Skipped

Looking at https://github.com/j178/prek/releases/tag/v0.2.15, I suspect this is due to #1087 ("Replace serde-yaml with serde_saphyr").

It doesn't like the final closing ] here:

- repo: https://github.com/pre-commit/mirrors-mypy
  rev: v1.18.2
  hooks:
  - id: mypy
    exclude: tests/data
    args: ["--pretty", "--show-error-codes"]
    additional_dependencies: [
        'keyring==24.2.0',
        'nox==2024.03.02',
        'pytest',
        'types-docutils==0.20.0.3',
        'types-setuptools==68.2.0.0',
        'types-freezegun==1.1.10',
        'types-pyyaml==6.0.12.12',
        'typing-extensions',
    ]

Platform

macOS 15 arm64

Version

prek 0.2.15 (11f369e 2025-11-17)

.pre-commit-config.yaml

exclude: 'src/pip/_vendor/'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v6.0.0
  hooks:
  - id: check-builtin-literals
  - id: check-added-large-files
  - id: check-case-conflict
  - id: check-toml
  - id: check-yaml
  - id: debug-statements
  - id: end-of-file-fixer
    exclude: WHEEL
  - id: forbid-new-submodules
  - id: trailing-whitespace
    exclude: .patch

- repo: https://github.com/psf/black-pre-commit-mirror
  rev: 25.9.0
  hooks:
  - id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
  rev: v0.14.3
  hooks:
    - id: ruff-check
      args: [--fix]

- repo: https://github.com/pre-commit/mirrors-mypy
  rev: v1.18.2
  hooks:
  - id: mypy
    exclude: tests/data
    args: ["--pretty", "--show-error-codes"]
    additional_dependencies: [
        'keyring==24.2.0',
        'nox==2024.03.02',
        'pytest',
        'types-docutils==0.20.0.3',
        'types-setuptools==68.2.0.0',
        'types-freezegun==1.1.10',
        'types-pyyaml==6.0.12.12',
        'typing-extensions',
    ]

- repo: https://github.com/pre-commit/pygrep-hooks
  rev: v1.10.0
  hooks:
  - id: python-no-log-warn
  - id: python-no-eval
  - id: rst-backticks
    files: .*\.rst$
    types: [file]
    exclude: NEWS.rst  # The errors flagged in NEWS.rst are old.

- repo: https://github.com/codespell-project/codespell
  rev: v2.4.1
  hooks:
    - id: codespell
      exclude: AUTHORS.txt|tests/data
      args: ["--ignore-words", tools/codespell-ignore.txt]

- repo: local
  hooks:
  - id: news-fragment-filenames
    name: NEWS fragment
    language: fail
    entry: NEWS fragment files must be named *.(process|removal|feature|bugfix|vendor|doc|trivial).rst
    exclude: ^news/(.gitignore|.*\.(process|removal|feature|bugfix|vendor|doc|trivial).rst)
    files: ^news/

ci:
  autofix_prs: false
  autoupdate_commit_msg: 'pre-commit autoupdate'
  autoupdate_schedule: monthly

Log file

2025-11-18T10:29:37.774220Z DEBUG prek: 0.2.16 (df5068a79 2025-11-18)
2025-11-18T10:29:37.774299Z DEBUG Args: ["prek", "run", "--all-files"]
2025-11-18T10:29:37.782074Z DEBUG Git root: /Users/hugo/github/pip
2025-11-18T10:29:37.782138Z DEBUG Found workspace root at `/Users/hugo/github/pip`
2025-11-18T10:29:37.782154Z TRACE Include selectors: ``
2025-11-18T10:29:37.782161Z TRACE Skip selectors: ``
2025-11-18T10:29:37.782221Z DEBUG discover{root="/Users/hugo/github/pip" config=None refresh=false}: Performing fresh workspace discovery
2025-11-18T10:29:37.783810Z DEBUG Loading project configuration path=.pre-commit-config.yaml
2025-11-18T10:29:37.785806Z TRACE discover{root="/Users/hugo/github/pip" config=None refresh=false}: close time.busy=3.60ms time.idle=3.54µs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions