You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When importing numpy>=2.0.0, report "AssertionError: Internal error: unresolved placeholder type None" when using stubgen #17538
When importing lastest version of numpy>=2.0.0, report "AssertionError: Internal error: unresolved placeholder type None" when using stubgen.
The error looks like this:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "D:\Program Files\Python\Python312\Scripts\stubgen.exe\__main__.py", line 7, in <module>
File "mypy\stubgen.py", line 1882, in main
File "mypy\stubgen.py", line 1678, in generate_stubs
File "mypy\stubgen.py", line 1610, in generate_asts_for_modules
File "mypy\build.py", line 192, in build
File "mypy\build.py", line 266, in _build
File "mypy\build.py", line 2942, in dispatch
File "mypy\build.py", line 3340, in process_graph
File "mypy\build.py", line 3468, in process_stale_scc
File "mypy\build.py", line 2503, in write_cache
File "mypy\build.py", line 1564, in write_cache
File "mypy\nodes.py", line 387, in serialize
File "mypy\nodes.py", line 3936, in serialize
File "mypy\nodes.py", line 3873, in serialize
File "mypy\nodes.py", line 3304, in serialize
File "mypy\types.py", line 667, in serialize
File "mypy\types.py", line 2430, in serialize
File "mypy\types.py", line 1468, in serialize
File "mypy\types.py", line 667, in serialize
File "mypy\types.py", line 3067, in serialize
AssertionError: Internal error: unresolved placeholder type None
To Reproduce
Install latest version of numpy>=2.0.0, then create a Python file with only this import, egg. foo.py.
importnumpy
using the stubgen command to generate pyi file
# stubgen .\foo.py
Expected Behavior
gernerated the pyi file via stubgen command
Actual Behavior
report "AssertionError: Internal error: unresolved placeholder type None" when using stubgen command.
I tried to downgrade numpy to numpy==1.26.4 and it worked.
Your Environment
Mypy version used: 1.10.1
Mypy command-line flags: stubgen .\foo.py
Mypy configuration options from mypy.ini (and other config files): default
Python version used: 3.12.3
Reacted by Francisco Dias, pi29511, Varun Agrawal, Avasam, Pieter Pas and Muhammad Hakim Asy'ari
Activity
fcdiass commentedon Jul 29, 2024
I have the same issue here. For now, the solution is to use version 1.26.4 of the Numpy...
fix: stubgen crashes for newer numpy versions
varunagrawal commentedon Aug 26, 2024
This is being tackled in #17396
brianschubert commentedon Jun 9, 2025
Fixed by #18585