E5A2 BUG: mypy --follow-imports error or skip crashes with numpy 2.0.0 · Issue #26720 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

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

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

Closed
tomsilver opened this issue Jun 17, 2024 · 6 comments
Closed

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

tomsilver opened this issue Jun 17, 2024 · 6 comments

Comments

@tomsilver
Copy link

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

@rgommers
Copy link
Member

Thanks for the bug report @tomsilver. I can reproduce the problem, I'm just not sure what to make of it yet. An "internal error" from Mypy with no other info to go on looks like a Mypy bug indeed, even if it's triggered by some issue in a numpy .pyi file. That should just never happen.

@vasudev13
Copy link

image

See similar effect/error when importing pandas with 2.0 version of numpy installed.

@rgommers
Copy link
Member

@vasudev13 that is a different error. You need to upgrade your installed pandas version; 2.2.2 is the first version that is compatible with numpy 2.0

@seberg
Copy link
Member
seberg commented Jun 17, 2024

Weird try, but if I add --cache-dir=/dev/null it works fine... None of the debug options like --pdb seem to go anywhere? Maybe already time to push this to mypy, if just to see if they have an idea what triggers this.

@rgommers
Copy link
Member

Thanks for opening a Mypy issue (python/mypy#17396) for this @tomsilver.

@rgommers
Copy link
Member

Closing this issue, since it's now confirmed that it's a Mypy bug and there is nothing to fix for this on the NumPy side. Thanks again @tomsilver

@rgommers rgommers closed this as not planned Won't fix, can't repro, duplicate, stale Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0