diff options
-rw-r--r-- | numpy/typing/_array_like.py | 2 | ||||
-rw-r--r-- | numpy/typing/_callable.py | 2 | ||||
-rw-r--r-- | numpy/typing/_char_codes.py | 2 | ||||
-rw-r--r-- | numpy/typing/_dtype_like.py | 5 |
4 files changed, 4 insertions, 7 deletions
diff --git a/numpy/typing/_array_like.py b/numpy/typing/_array_like.py index 187dfb96a..3bdbed8f8 100644 --- a/numpy/typing/_array_like.py +++ b/numpy/typing/_array_like.py @@ -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. diff --git a/numpy/typing/_callable.py b/numpy/typing/_callable.py index 52573f648..8f911da3b 100644 --- a/numpy/typing/_callable.py +++ b/numpy/typing/_callable.py @@ -53,7 +53,7 @@ if sys.version_info >= (3, 8): elif _HAS_TYPING_EXTENSIONS: from typing_extensions import Protocol -if TYPE_CHECKING or _HAS_TYPING_EXTENSIONS: +if TYPE_CHECKING or _HAS_TYPING_EXTENSIONS or sys.version_info >= (3, 8): _T1 = TypeVar("_T1") _T2 = TypeVar("_T2") _2Tuple = Tuple[_T1, _T1] diff --git a/numpy/typing/_char_codes.py b/numpy/typing/_char_codes.py index 24d39c62e..22ee168e9 100644 --- a/numpy/typing/_char_codes.py +++ b/numpy/typing/_char_codes.py @@ -8,7 +8,7 @@ if sys.version_info >= (3, 8): elif _HAS_TYPING_EXTENSIONS: from typing_extensions import Literal -if TYPE_CHECKING or _HAS_TYPING_EXTENSIONS: +if TYPE_CHECKING or _HAS_TYPING_EXTENSIONS or sys.version_info >= (3, 8): _BoolCodes = Literal["?", "=?", "<?", ">?", "bool", "bool_", "bool8"] _UInt8Codes = Literal["uint8", "u1", "=u1", "<u1", ">u1"] diff --git a/numpy/typing/_dtype_like.py b/numpy/typing/_dtype_like.py index 061b4c0ed..b2ce3adb4 100644 --- a/numpy/typing/_dtype_like.py +++ b/numpy/typing/_dtype_like.py @@ -11,9 +11,6 @@ if sys.version_info >= (3, 8): from typing import Protocol, TypedDict elif _HAS_TYPING_EXTENSIONS: from typing_extensions import Protocol, TypedDict - -if sys.version_info >= (3, 9): - from types import GenericAlias else: from ._generic_alias import _GenericAlias as GenericAlias @@ -62,7 +59,7 @@ from ._char_codes import ( _DTypeLikeNested = Any # TODO: wait for support for recursive types _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): # Mandatory keys class _DTypeDictBase(TypedDict): names: Sequence[str] |