KEMBAR78
BUG: mypy --follow-imports error or skip crashes with numpy 2.0.0 · Issue #26720 · numpy/numpy · GitHub
Skip to content

BUG: mypy --follow-imports error or skip crashes with numpy 2.0.0 #26720

@tomsilver

Description

@tomsilver

Describe the issue:

This may be a mypy bug, but it only emerged with numpy==2.0.0.

Steps to reproduce:

  1. pip install numpy mypy
  2. echo "import numpy" > test.py
  3. mypy test.py --follow-imports error

The crash is shown below. Notes:

  • The crash does not happen with numpy==1.26.4
  • The same crash happens with mypy test.py --follow-imports skip
  • It does not happen with mypy test.py --follow-imports normal

Reproduce the code example:

# See description (must run mypy)
import numpy as np

Error message:

Traceback (most recent call last):
  File "/Users/tom/Desktop/venv/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
  File "/Users/tom/Desktop/venv/lib/python3.10/site-packages/mypy/__main__.py", line 15, in console_entry
    main()
  File "mypy/main.py", line 100, in main
  File "mypy/main.py", line 182, in run_build
  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 3467, 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

Python and NumPy Versions:

2.0.0
3.10.6 (main, Dec 5 2022, 17:11:59) [Clang 13.1.6 (clang-1316.0.21.2.5)]

Runtime Environment:

[{'numpy_version': '2.0.0',
'python': '3.10.6 (main, Dec 5 2022, 17:11:59) [Clang 13.1.6 '
'(clang-1316.0.21.2.5)]',
'uname': uname_result(system='Darwin', node='Toms-MacBook-Pro-4.local', release='21.6.0', version='Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000', machine='arm64')},
{'simd_extensions': {'baseline': ['NEON', 'NEON_FP16', 'NEON_VFPV4', 'ASIMD'],
'found': ['ASIMDHP'],
'not_found': ['ASIMDFHM']}},
{'architecture': 'neoversen1',
'filepath': '/Users/tom/Desktop/venv/lib/python3.10/site-packages/numpy/.dylibs/libscipy_openblas64_.dylib',
'internal_api': 'openblas',
'num_threads': 10,
'prefix': 'libscipy_openblas',
'threading_layer': 'pthreads',
'user_api': 'blas',
'version': '0.3.27'}]

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions