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

Importing ArrayLike or DTypeLike raises a NameError in numpy 1.21.1 #19521

Closed
hhtong opened this issue Jul 19, 2021 · 4 comments · Fixed by #19533
Closed

Importing ArrayLike or DTypeLike raises a NameError in numpy 1.21.1 #19521

hhtong opened this issue Jul 19, 2021 · 4 comments · Fixed by #19533

Comments

@hhtong
Copy link

hhtong commented Jul 19, 2021

With python 3.7.9, importing ArrayLike or DTypeLike raises a NameError in numpy==1.21.1.

I had expected that the TypeError raised with numpy==1.21.0 would have been resolved with this PR : #19311, but now a NameError comes up instead.

Reproducing code example:

from numpy.typing import ArrayLike, DTypeLike

Error message:

>>> from numpy.typing import ArrayLike, DTypeLike
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/htong/env379/lib/python3.7/site-packages/numpy/typing/__init__.py", line 316, in <module>
    from ._dtype_like import (
  File "/Users/htong/env379/lib/python3.7/site-packages/numpy/typing/_dtype_like.py", line 95, in <module>
    class _SupportsDType(Generic[_DType_co]):
NameError: name '_DType_co' is not defined

NumPy/Python version information:

>>> import sys, numpy; print(numpy.__version__, sys.version)
1.21.1 3.7.9 (default, Jul 16 2021, 10:15:27) 
[Clang 11.0.0 (clang-1100.0.33.16)]
@sourabh69733
Copy link

Try to update your python to 3.8+ or 3.9.1.

It is not throwing an error in 3.9.1.

numpy_error_image

@sourabh69733
Copy link

Check here the documentation reference for the previous version of python

@BvB93
Copy link
Member

BvB93 commented Jul 21, 2021

The condition for triggering the exception is as following:

  • Python 3.7 is used.
  • typing-extensions is not installed.

I'm currently working a fix for the issue. Annoyingly enough the relevant code paths have proven difficult to test,
as typing-extensions is an (indirect) dependency of pytest. #19525 should help with this though.

@BvB93
Copy link
Member

BvB93 commented Jul 22, 2021

Closed by #19533.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants