mypy crashes on a dataclass
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Crash Report
Traceback
Traceback (most recent call last):
File "/home/dnpetrov/Work/memory_tests/venv/bin/mypy", line 8, in <module>
sys.exit(console_entry())
^^^^^^^^^^^^^^^
File "/home/dnpetrov/Work/memory_tests/venv/lib/python3.12/site-packages/mypy/__main__.py", line 15, in console_entry
main()
File "mypy/main.py", line 103, in main
File "mypy/main.py", line 187, in run_build
File "mypy/build.py", line 193, in build
File "mypy/build.py", line 268, in _build
File "mypy/build.py", line 2950, in dispatch
File "mypy/build.py", line 3348, in process_graph
File "mypy/build.py", line 3443, in process_stale_scc
File "mypy/semanal_main.py", line 99, in semantic_analysis_for_scc
File "mypy/semanal_main.py", line 432, in apply_class_plugin_hooks
AssertionError: Internal error: too many class plugin hook passes
To Reproduce
Following code crashes mypy:
from dataclasses import dataclass
def fn(a: int) -> int:
return a
@dataclass
class Test:
foo = fn
foo: int = 42
While the code itself, indeed, looks very strange, mypy should not crash, or at least should provide some meaningful diagnostic instead of "Internal error: too many class plugin hook passes".
Your Environment
$ mypy --version
mypy 1.11.2 (compiled: yes)
$ python --version
Python 3.12.3
Also reproduces on the latest and greatest master branch (30b2a2d99a05c5176eff449b80abb61eae5f2043).
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 crash with the dataclass example, then inspect mypy/semanal_main.py at apply_class_plugin_hooks and the related processing in mypy/build.py. Trace why the class plugin hook pass limit is reached; done means this input no longer crashes and instead produces a meaningful diagnostic or completes successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100