Skip to content

[BUG] required default_language_version in precommit config #138

@Besthope-Official

Description

@Besthope-Official

Problem

debug-statements hook fails with SyntaxError on Python 3.10+ match statement (uses Python 3.9 env)

When running pre-commit, the debug-statements hook (from pre-commit/pre-commit-hooks) fails to parse files containing Python 3.10+ match / case statements.

src/core/loop/hooks.py - Could not parse ast

	Traceback (most recent call last):
	  File "/home/**/.cache/pre-commit/repof90bh73l/py_env-python3/lib/python3.9/site-packages/pre_commit_hooks/debug_statement_hook.py", line 57, in check_file
	    ast_obj = ast.parse(f.read(), filename=filename)
	  File "/home/**/.local/share/uv/python/cpython-3.9.0-linux-x86_64-gnu/lib/python3.9/ast.py", line 50, in parse
	    return compile(source, filename, mode, flags,
	  File "src/core/loop/hooks.py", line 15
	    match event.name:
	          ^
	SyntaxError: invalid syntax

Minimal Reproducible Example

def handle_event(event):
    match event.name:   # Python 3.10+ syntax
        case "start":
            print("Starting...")
        case _:
            pass

add this in vcs

Suggestions

default_language_version:
  python: python3.11   # or python3.12 / python3.10 (match your project)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions