Using the pre-commit mypy plugin throws internal library errors
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with pre-commit run mypy using Python 3.12, mypy 1.18.2, and the listed flags, then compare it with the command-line invocation. Start at the semantic analyzer traceback in mypy/semanal.py and the django-stubs/http/request.pyi:56 annotation. Done means the pre-commit hook completes without the INTERNAL ERROR while checking the same files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100