summaryrefslogtreecommitdiff
path: root/numpy/typing/_array_like.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/typing/_array_like.py')
-rw-r--r--numpy/typing/_array_like.py6
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[