Skip to content

Using the pre-commit mypy plugin throws internal library errors #19912

@bulldogukbcm

Description

@bulldogukbcm

Using the pre-commit implementation of mypy throws an INTERNAL ERROR on a project that was previously working. Note that running the same version of mypy from the command line against the same files (in a devcontainer) works as expected.

Pre-commit project can be found at: https://github.com/pre-commit/pre-commit Version 4.3.0

From the pre-commit configuration: running mypy v1.18.2

To Reproduce

Create python project, configure git and install the pre-commit hook

Expected Behavior

Expected to run mypy testing on changed files as usual.

Actual Behavior

vscode ➜ /workspace/internalapi (internalapi_apm_and_logs) $ pre-commit run mypy
mypy.....................................................................Failed
- hook id: mypy
- exit code: 2

/home/vscode/.cache/pre-commit/repo3uyifmwv/py_env-python3.12/lib/python3.12/site-packages/django-stubs/http/request.pyi:56: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.18.2
Traceback (most recent call last):
  File "mypy/semanal.py", line 7350, in accept
  File "mypy/nodes.py", line 1624, in accept
  File "mypy/semanal.py", line 3272, in visit_assignment_stmt
  File "mypy/semanal.py", line 3806, in process_type_annotation
  File "mypy/semanal.py", line 6996, in defer
AssertionError: Must not defer during final iteration
/home/vscode/.cache/pre-commit/repo3uyifmwv/py_env-python3.12/lib/python3.12/site-packages/django-stubs/http/request.pyi:56: : note: use --pdb to drop into pdb

Your Environment

  • Mypy version used: 1.18.2
  • Mypy command-line flags: --show-traceback, --check-untyped-defs, --ignore-missing-imports, --config-file=pyproject.toml
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions