Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When importing numpy>=2.0.0, report "AssertionError: Internal error: unresolved placeholder type None" when using stubgen #17538

Open
JunChen1990 opened this issue Jul 19, 2024 · 2 comments
Labels
bug mypy got something wrong

Comments

@JunChen1990
Copy link

JunChen1990 commented Jul 19, 2024

Bug Report

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.

import numpy

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
@JunChen1990 JunChen1990 added the bug mypy got something wrong label Jul 19, 2024
@fcdiass
Copy link

fcdiass commented Jul 29, 2024

I have the same issue here. For now, the solution is to use version 1.26.4 of the Numpy...

@varunagrawal
Copy link

This is being tackled in #17396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

3 participants