Skip to content

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

Open
@JunChen1990

Description

@JunChen1990

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongcrash

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions