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.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/numpy/typing/_array_like.py b/numpy/typing/_array_like.py
index 2283c98d7..2b823ecc0 100644
--- a/numpy/typing/_array_like.py
+++ b/numpy/typing/_array_like.py
@@ -21,23 +21,20 @@ from numpy import (
bytes_,
)
+from . import _HAS_TYPING_EXTENSIONS
+from ._dtype_like import DTypeLike
+
if sys.version_info >= (3, 8):
from typing import Protocol
- HAVE_PROTOCOL = True
-else:
- try:
- from typing_extensions import Protocol
- except ImportError:
- HAVE_PROTOCOL = False
- else:
- HAVE_PROTOCOL = True
+elif _HAS_TYPING_EXTENSIONS:
+ from typing_extensions import Protocol
_T = TypeVar("_T")
_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 HAVE_PROTOCOL:
+if TYPE_CHECKING or _HAS_TYPING_EXTENSIONS:
# 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.