diff options
author | MarsBarLee <46167686+MarsBarLee@users.noreply.github.com> | 2021-06-08 14:50:40 -0400 |
---|---|---|
committer | MarsBarLee <46167686+MarsBarLee@users.noreply.github.com> | 2021-06-08 14:50:40 -0400 |
commit | d1134930c8dfef8ea935d5c4f2b6ee6613a03d82 (patch) | |
tree | a4cfc29a37cc93a9dcc076b7d818ca9e604e0095 /numpy/typing/_array_like.py | |
parent | 9964bf877277f31fb5f0092a36b51bf6782366ce (diff) | |
parent | b9a63f5052b0ba5a7a5b2616ddcc1754df177bd3 (diff) | |
download | numpy-d1134930c8dfef8ea935d5c4f2b6ee6613a03d82.tar.gz |
Merge branch 'numpy:main' into crosslink-gitpod
Diffstat (limited to 'numpy/typing/_array_like.py')
-rw-r--r-- | numpy/typing/_array_like.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/numpy/typing/_array_like.py b/numpy/typing/_array_like.py index 2b823ecc0..3bdbed8f8 100644 --- a/numpy/typing/_array_like.py +++ b/numpy/typing/_array_like.py @@ -1,7 +1,7 @@ from __future__ import annotations import sys -from typing import Any, Sequence, TYPE_CHECKING, Union, TypeVar +from typing import Any, Sequence, TYPE_CHECKING, Union, TypeVar, Generic from numpy import ( ndarray, @@ -34,7 +34,7 @@ _ScalarType = TypeVar("_ScalarType", bound=generic) _DType = TypeVar("_DType", bound="dtype[Any]") _DType_co = TypeVar("_DType_co", covariant=True, bound="dtype[Any]") -if TYPE_CHECKING or _HAS_TYPING_EXTENSIONS: +if TYPE_CHECKING or _HAS_TYPING_EXTENSIONS or sys.version_info >= (3, 8): # The `_SupportsArray` protocol only cares about the default dtype # (i.e. `dtype=None` or no `dtype` parameter at all) of the to-be returned # array. @@ -43,7 +43,7 @@ if TYPE_CHECKING or _HAS_TYPING_EXTENSIONS: class _SupportsArray(Protocol[_DType_co]): def __array__(self) -> ndarray[Any, _DType_co]: ... else: - _SupportsArray = Any + class _SupportsArray(Generic[_DType_co]): ... # TODO: Wait for support for recursive types _NestedSequence = Union[ |