summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <43369155+BvB93@users.noreply.github.com>2021-08-14 22:02:29 +0200
committerBas van Beek <b.f.van.beek@vu.nl>2021-08-30 15:26:54 +0200
commit355336119136f620c27f1adcc26074eb9528c159 (patch)
tree6d64faab94a767d361fa2c0f87f0f26b2e75fc25
parentd0b676b77bfa567eddb925bc31ead24ff0b576b1 (diff)
downloadnumpy-355336119136f620c27f1adcc26074eb9528c159.tar.gz
MAINT: Drop .pyi code-paths specific to Python 3.7
-rw-r--r--numpy/__init__.pyi41
-rw-r--r--numpy/_pytesttester.pyi3
-rw-r--r--numpy/core/_asarray.pyi8
-rw-r--r--numpy/core/_type_aliases.pyi8
-rw-r--r--numpy/core/_ufunc_config.pyi8
-rw-r--r--numpy/core/arrayprint.pyi8
-rw-r--r--numpy/core/einsumfunc.pyi8
-rw-r--r--numpy/core/fromnumeric.pyi8
-rw-r--r--numpy/core/function_base.pyi8
-rw-r--r--numpy/core/multiarray.pyi10
-rw-r--r--numpy/core/numeric.pyi7
-rw-r--r--numpy/core/numerictypes.pyi8
-rw-r--r--numpy/core/shape_base.pyi8
-rw-r--r--numpy/f2py/__init__.pyi3
-rw-r--r--numpy/lib/arraypad.pyi8
-rw-r--r--numpy/lib/arrayterator.pyi1
-rw-r--r--numpy/lib/format.pyi8
-rw-r--r--numpy/lib/index_tricks.pyi8
-rw-r--r--numpy/lib/npyio.pyi4
-rw-r--r--numpy/lib/shape_base.pyi3
-rw-r--r--numpy/lib/stride_tricks.pyi3
-rw-r--r--numpy/lib/type_check.pyi8
-rw-r--r--numpy/lib/utils.pyi7
-rw-r--r--numpy/random/_generator.pyi8
-rw-r--r--numpy/random/_mt19937.pyi8
-rw-r--r--numpy/random/_pcg64.pyi8
-rw-r--r--numpy/random/_philox.pyi8
-rw-r--r--numpy/random/_sfc64.pyi8
-rw-r--r--numpy/random/bit_generator.pyi7
-rw-r--r--numpy/random/mtrand.pyi8
-rw-r--r--numpy/testing/_private/utils.pyi8
-rw-r--r--numpy/typing/_ufunc.pyi4
-rw-r--r--numpy/typing/tests/data/reveal/arraypad.py3
33 files changed, 57 insertions, 199 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index fb68f4a56..f398f67b7 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -164,6 +164,7 @@ from numpy.typing._extended_precision import (
)
from typing import (
+ Literal as L,
Any,
ByteString,
Callable,
@@ -189,13 +190,11 @@ from typing import (
Type,
TypeVar,
Union,
+ Protocol,
+ SupportsIndex,
+ Final,
)
-if sys.version_info >= (3, 8):
- from typing import Literal as L, Protocol, SupportsIndex, Final
-else:
- from typing_extensions import Literal as L, Protocol, SupportsIndex, Final
-
# Ensures that the stubs are picked up
from numpy import (
char as char,
@@ -3163,28 +3162,16 @@ class datetime64(generic):
__gt__: _ComparisonOp[datetime64, _ArrayLikeDT64_co]
__ge__: _ComparisonOp[datetime64, _ArrayLikeDT64_co]
-# Support for `__index__` was added in python 3.8 (bpo-20092)
-if sys.version_info >= (3, 8):
- _IntValue = Union[SupportsInt, _CharLike_co, SupportsIndex]
- _FloatValue = Union[None, _CharLike_co, SupportsFloat, SupportsIndex]
- _ComplexValue = Union[
- None,
- _CharLike_co,
- SupportsFloat,
- SupportsComplex,
- SupportsIndex,
- complex, # `complex` is not a subtype of `SupportsComplex`
- ]
-else:
- _IntValue = Union[SupportsInt, _CharLike_co]
- _FloatValue = Union[None, _CharLike_co, SupportsFloat]
- _ComplexValue = Union[
- None,
- _CharLike_co,
- SupportsFloat,
- SupportsComplex,
- complex,
- ]
+_IntValue = Union[SupportsInt, _CharLike_co, SupportsIndex]
+_FloatValue = Union[None, _CharLike_co, SupportsFloat, SupportsIndex]
+_ComplexValue = Union[
+ None,
+ _CharLike_co,
+ SupportsFloat,
+ SupportsComplex,
+ SupportsIndex,
+ complex, # `complex` is not a subtype of `SupportsComplex`
+]
class integer(number[_NBit1]): # type: ignore
@property
diff --git a/numpy/_pytesttester.pyi b/numpy/_pytesttester.pyi
index 693f4128a..0be64b3f7 100644
--- a/numpy/_pytesttester.pyi
+++ b/numpy/_pytesttester.pyi
@@ -1,5 +1,4 @@
-from typing import List, Iterable
-from typing_extensions import Literal as L
+from typing import List, Iterable, Literal as L
__all__: List[str]
diff --git a/numpy/core/_asarray.pyi b/numpy/core/_asarray.pyi
index 1928cfe12..fee9b7b6e 100644
--- a/numpy/core/_asarray.pyi
+++ b/numpy/core/_asarray.pyi
@@ -1,14 +1,8 @@
-import sys
-from typing import TypeVar, Union, Iterable, overload
+from typing import TypeVar, Union, Iterable, overload, Literal
from numpy import ndarray
from numpy.typing import ArrayLike, DTypeLike
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
_ArrayType = TypeVar("_ArrayType", bound=ndarray)
_Requirements = Literal[
diff --git a/numpy/core/_type_aliases.pyi b/numpy/core/_type_aliases.pyi
index 6a1099cd3..c10d072f9 100644
--- a/numpy/core/_type_aliases.pyi
+++ b/numpy/core/_type_aliases.pyi
@@ -1,13 +1,7 @@
-import sys
-from typing import Dict, Union, Type, List
+from typing import Dict, Union, Type, List, TypedDict
from numpy import generic, signedinteger, unsignedinteger, floating, complexfloating
-if sys.version_info >= (3, 8):
- from typing import TypedDict
-else:
- from typing_extensions import TypedDict
-
class _SCTypes(TypedDict):
int: List[Type[signedinteger]]
uint: List[Type[unsignedinteger]]
diff --git a/numpy/core/_ufunc_config.pyi b/numpy/core/_ufunc_config.pyi
index e90f1c510..aa48ddba7 100644
--- a/numpy/core/_ufunc_config.pyi
+++ b/numpy/core/_ufunc_config.pyi
@@ -1,10 +1,4 @@
-import sys
-from typing import Optional, Union, Callable, Any
-
-if sys.version_info >= (3, 8):
- from typing import Literal, Protocol, TypedDict
-else:
- from typing_extensions import Literal, Protocol, TypedDict
+from typing import Optional, Union, Callable, Any, Literal, Protocol, TypedDict
_ErrKind = Literal["ignore", "warn", "raise", "call", "print", "log"]
_ErrFunc = Callable[[str, int], Any]
diff --git a/numpy/core/arrayprint.pyi b/numpy/core/arrayprint.pyi
index ac2b6f5a8..df22efed6 100644
--- a/numpy/core/arrayprint.pyi
+++ b/numpy/core/arrayprint.pyi
@@ -1,6 +1,5 @@
-import sys
from types import TracebackType
-from typing import Any, Optional, Callable, Union, Type
+from typing import Any, Optional, Callable, Union, Type, Literal, TypedDict, SupportsIndex
# Using a private class is by no means ideal, but it is simply a consquence
# of a `contextlib.context` returning an instance of aformentioned class
@@ -23,11 +22,6 @@ from numpy import (
)
from numpy.typing import ArrayLike, _CharLike_co, _FloatLike_co
-if sys.version_info > (3, 8):
- from typing import Literal, TypedDict, SupportsIndex
-else:
- from typing_extensions import Literal, TypedDict, SupportsIndex
-
_FloatMode = Literal["fixed", "unique", "maxprec", "maxprec_equal"]
class _FormatDict(TypedDict, total=False):
diff --git a/numpy/core/einsumfunc.pyi b/numpy/core/einsumfunc.pyi
index 2457e8719..bb02590e6 100644
--- a/numpy/core/einsumfunc.pyi
+++ b/numpy/core/einsumfunc.pyi
@@ -1,5 +1,4 @@
-import sys
-from typing import List, TypeVar, Optional, Any, overload, Union, Tuple, Sequence
+from typing import List, TypeVar, Optional, Any, overload, Union, Tuple, Sequence, Literal
from numpy import (
ndarray,
@@ -26,11 +25,6 @@ from numpy.typing import (
_DTypeLikeComplex_co,
)
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
_ArrayType = TypeVar(
"_ArrayType",
bound=ndarray[Any, dtype[Union[bool_, number[Any]]]],
diff --git a/numpy/core/fromnumeric.pyi b/numpy/core/fromnumeric.pyi
index 45057e4b1..3cbe1d5c5 100644
--- a/numpy/core/fromnumeric.pyi
+++ b/numpy/core/fromnumeric.pyi
@@ -1,6 +1,5 @@
-import sys
import datetime as dt
-from typing import Optional, Union, Sequence, Tuple, Any, overload, TypeVar
+from typing import Optional, Union, Sequence, Tuple, Any, overload, TypeVar, Literal
from numpy import (
ndarray,
@@ -26,11 +25,6 @@ from numpy.typing import (
_NumberLike_co,
)
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
# Various annotations for scalars
# While dt.datetime and dt.timedelta are not technically part of NumPy,
diff --git a/numpy/core/function_base.pyi b/numpy/core/function_base.pyi
index b5d6ca6ab..c35629aa7 100644
--- a/numpy/core/function_base.pyi
+++ b/numpy/core/function_base.pyi
@@ -1,14 +1,8 @@
-import sys
-from typing import overload, Tuple, Union, Sequence, Any
+from typing import overload, Tuple, Union, Sequence, Any, SupportsIndex, Literal
from numpy import ndarray
from numpy.typing import ArrayLike, DTypeLike, _SupportsArray, _NumberLike_co
-if sys.version_info >= (3, 8):
- from typing import SupportsIndex, Literal
-else:
- from typing_extensions import SupportsIndex, Literal
-
# TODO: wait for support for recursive types
_ArrayLikeNested = Sequence[Sequence[Any]]
_ArrayLikeNumber = Union[
diff --git a/numpy/core/multiarray.pyi b/numpy/core/multiarray.pyi
index a7d2e6bbf..b807ddff0 100644
--- a/numpy/core/multiarray.pyi
+++ b/numpy/core/multiarray.pyi
@@ -1,9 +1,9 @@
# TODO: Sort out any and all missing functions in this namespace
import os
-import sys
import datetime as dt
from typing import (
+ Literal as L,
Any,
Callable,
IO,
@@ -16,6 +16,9 @@ from typing import (
Union,
Sequence,
Tuple,
+ SupportsIndex,
+ final,
+ Final,
)
from numpy import (
@@ -78,11 +81,6 @@ from numpy.typing import (
_TD64Like_co,
)
-if sys.version_info >= (3, 8):
- from typing import SupportsIndex, final, Final, Literal as L
-else:
- from typing_extensions import SupportsIndex, final, Final, Literal as L
-
_SCT = TypeVar("_SCT", bound=generic)
_ArrayType = TypeVar("_ArrayType", bound=NDArray[Any])
diff --git a/numpy/core/numeric.pyi b/numpy/core/numeric.pyi
index 3c2b553ec..54ab4b7c8 100644
--- a/numpy/core/numeric.pyi
+++ b/numpy/core/numeric.pyi
@@ -1,4 +1,3 @@
-import sys
from typing import (
Any,
Optional,
@@ -10,16 +9,12 @@ from typing import (
overload,
TypeVar,
Iterable,
+ Literal,
)
from numpy import ndarray, generic, dtype, bool_, signedinteger, _OrderKACF, _OrderCF
from numpy.typing import ArrayLike, DTypeLike, _ShapeLike
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
_T = TypeVar("_T")
_ArrayType = TypeVar("_ArrayType", bound=ndarray)
diff --git a/numpy/core/numerictypes.pyi b/numpy/core/numerictypes.pyi
index d5e3ccffb..1d3ff773b 100644
--- a/numpy/core/numerictypes.pyi
+++ b/numpy/core/numerictypes.pyi
@@ -1,6 +1,7 @@
import sys
import types
from typing import (
+ Literal as L,
Type,
Union,
Tuple,
@@ -10,6 +11,8 @@ from typing import (
Dict,
List,
Iterable,
+ Protocol,
+ TypedDict,
)
from numpy import (
@@ -49,11 +52,6 @@ from numpy.core._type_aliases import (
from numpy.typing import DTypeLike, ArrayLike, _SupportsDType
-if sys.version_info >= (3, 8):
- from typing import Literal as L, Protocol, TypedDict
-else:
- from typing_extensions import Literal as L, Protocol, TypedDict
-
_T = TypeVar("_T")
_SCT = TypeVar("_SCT", bound=generic)
diff --git a/numpy/core/shape_base.pyi b/numpy/core/shape_base.pyi
index 9aaeceed7..a640991d3 100644
--- a/numpy/core/shape_base.pyi
+++ b/numpy/core/shape_base.pyi
@@ -1,14 +1,8 @@
-import sys
-from typing import TypeVar, overload, List, Sequence, Any
+from typing import TypeVar, overload, List, Sequence, Any, SupportsIndex
from numpy import generic, dtype
from numpy.typing import ArrayLike, NDArray, _NestedSequence, _SupportsArray
-if sys.version_info >= (3, 8):
- from typing import SupportsIndex
-else:
- from typing_extensions import SupportsIndex
-
_SCT = TypeVar("_SCT", bound=generic)
_ArrayType = TypeVar("_ArrayType", bound=NDArray[Any])
diff --git a/numpy/f2py/__init__.pyi b/numpy/f2py/__init__.pyi
index 7d8e092ea..e52e12bbd 100644
--- a/numpy/f2py/__init__.pyi
+++ b/numpy/f2py/__init__.pyi
@@ -1,7 +1,6 @@
import os
import subprocess
-from typing import Any, List, Iterable, Dict, overload
-from typing_extensions import TypedDict, Literal as L
+from typing import Literal as L, Any, List, Iterable, Dict, overload, TypedDict
from numpy._pytesttester import PytestTester
diff --git a/numpy/lib/arraypad.pyi b/numpy/lib/arraypad.pyi
index df9538dd7..d6e07a6bd 100644
--- a/numpy/lib/arraypad.pyi
+++ b/numpy/lib/arraypad.pyi
@@ -1,11 +1,12 @@
-import sys
from typing import (
+ Literal as L,
Any,
Dict,
List,
overload,
Tuple,
TypeVar,
+ Protocol,
)
from numpy import ndarray, dtype, generic
@@ -18,11 +19,6 @@ from numpy.typing import (
_SupportsArray,
)
-if sys.version_info >= (3, 8):
- from typing import Literal as L, Protocol
-else:
- from typing_extensions import Literal as L, Protocol
-
_SCT = TypeVar("_SCT", bound=generic)
class _ModeFunc(Protocol):
diff --git a/numpy/lib/arrayterator.pyi b/numpy/lib/arrayterator.pyi
index 39d6fd843..82c669206 100644
--- a/numpy/lib/arrayterator.pyi
+++ b/numpy/lib/arrayterator.pyi
@@ -1,4 +1,3 @@
-import sys
from typing import (
List,
Any,
diff --git a/numpy/lib/format.pyi b/numpy/lib/format.pyi
index 4c44d57bf..092245daf 100644
--- a/numpy/lib/format.pyi
+++ b/numpy/lib/format.pyi
@@ -1,10 +1,4 @@
-import sys
-from typing import Any, List, Set
-
-if sys.version_info >= (3, 8):
- from typing import Literal, Final
-else:
- from typing_extensions import Literal, Final
+from typing import Any, List, Set, Literal, Final
__all__: List[str]
diff --git a/numpy/lib/index_tricks.pyi b/numpy/lib/index_tricks.pyi
index 0f9ae94a9..530be3cae 100644
--- a/numpy/lib/index_tricks.pyi
+++ b/numpy/lib/index_tricks.pyi
@@ -1,4 +1,3 @@
-import sys
from typing import (
Any,
Tuple,
@@ -8,6 +7,8 @@ from typing import (
List,
Union,
Sequence,
+ Literal,
+ SupportsIndex,
)
from numpy import (
@@ -49,11 +50,6 @@ from numpy.core.multiarray import (
ravel_multi_index as ravel_multi_index,
)
-if sys.version_info >= (3, 8):
- from typing import Literal, SupportsIndex
-else:
- from typing_extensions import Literal, SupportsIndex
-
_T = TypeVar("_T")
_DType = TypeVar("_DType", bound=dtype[Any])
_BoolType = TypeVar("_BoolType", Literal[True], Literal[False])
diff --git a/numpy/lib/npyio.pyi b/numpy/lib/npyio.pyi
index de6bc3ded..1321afb55 100644
--- a/numpy/lib/npyio.pyi
+++ b/numpy/lib/npyio.pyi
@@ -3,6 +3,7 @@ import sys
import zipfile
import types
from typing import (
+ Literal as L,
Any,
Mapping,
TypeVar,
@@ -16,6 +17,7 @@ from typing import (
Sequence,
Callable,
Pattern,
+ Protocol,
)
from numpy import (
@@ -36,8 +38,6 @@ from numpy.core.multiarray import (
unpackbits as unpackbits,
)
-from typing_extensions import Protocol, Literal as L
-
_T = TypeVar("_T")
_T_contra = TypeVar("_T_contra", contravariant=True)
_T_co = TypeVar("_T_co", covariant=True)
diff --git a/numpy/lib/shape_base.pyi b/numpy/lib/shape_base.pyi
index cfb3040b7..4c275cc8c 100644
--- a/numpy/lib/shape_base.pyi
+++ b/numpy/lib/shape_base.pyi
@@ -1,5 +1,4 @@
-from typing import List, TypeVar, Callable, Sequence, Any, overload, Tuple
-from typing_extensions import SupportsIndex, Protocol
+from typing import List, TypeVar, Callable, Sequence, Any, overload, Tuple, SupportsIndex, Protocol
from numpy import (
generic,
diff --git a/numpy/lib/stride_tricks.pyi b/numpy/lib/stride_tricks.pyi
index 9e4e46b8b..bafc46e9c 100644
--- a/numpy/lib/stride_tricks.pyi
+++ b/numpy/lib/stride_tricks.pyi
@@ -1,5 +1,4 @@
-from typing import Any, List, Dict, Iterable, TypeVar, overload
-from typing_extensions import SupportsIndex
+from typing import Any, List, Dict, Iterable, TypeVar, overload, SupportsIndex
from numpy import dtype, generic
from numpy.typing import (
diff --git a/numpy/lib/type_check.pyi b/numpy/lib/type_check.pyi
index fbe325858..5eb0e62d2 100644
--- a/numpy/lib/type_check.pyi
+++ b/numpy/lib/type_check.pyi
@@ -1,5 +1,5 @@
-import sys
from typing import (
+ Literal as L,
Any,
Container,
Iterable,
@@ -7,6 +7,7 @@ from typing import (
overload,
Type,
TypeVar,
+ Protocol,
)
from numpy import (
@@ -32,11 +33,6 @@ from numpy.typing import (
_DTypeLikeComplex,
)
-if sys.version_info >= (3, 8):
- from typing import Protocol, Literal as L
-else:
- from typing_extensions import Protocol, Literal as L
-
_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_SCT = TypeVar("_SCT", bound=generic)
diff --git a/numpy/lib/utils.pyi b/numpy/lib/utils.pyi
index 0518655c6..c13a219b5 100644
--- a/numpy/lib/utils.pyi
+++ b/numpy/lib/utils.pyi
@@ -1,4 +1,3 @@
-import sys
from ast import AST
from typing import (
Any,
@@ -11,6 +10,7 @@ from typing import (
Tuple,
TypeVar,
Union,
+ Protocol,
)
from numpy import ndarray, generic
@@ -21,11 +21,6 @@ from numpy.core.numerictypes import (
issubsctype as issubsctype,
)
-if sys.version_info >= (3, 8):
- from typing import Protocol
-else:
- from typing_extensions import Protocol
-
_T_contra = TypeVar("_T_contra", contravariant=True)
_FuncType = TypeVar("_FuncType", bound=Callable[..., Any])
diff --git a/numpy/random/_generator.pyi b/numpy/random/_generator.pyi
index 14dc55131..64b683d7c 100644
--- a/numpy/random/_generator.pyi
+++ b/numpy/random/_generator.pyi
@@ -1,5 +1,4 @@
-import sys
-from typing import Any, Callable, Dict, Optional, Tuple, Type, Union, overload, TypeVar
+from typing import Any, Callable, Dict, Optional, Tuple, Type, Union, overload, TypeVar, Literal
from numpy import (
bool_,
@@ -44,11 +43,6 @@ from numpy.typing import (
_UIntCodes,
)
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
_ArrayType = TypeVar("_ArrayType", bound=ndarray[Any, Any])
_DTypeLikeFloat32 = Union[
diff --git a/numpy/random/_mt19937.pyi b/numpy/random/_mt19937.pyi
index 1b8bacdae..820f27392 100644
--- a/numpy/random/_mt19937.pyi
+++ b/numpy/random/_mt19937.pyi
@@ -1,15 +1,9 @@
-import sys
-from typing import Any, Union
+from typing import Any, Union, TypedDict
from numpy import dtype, ndarray, uint32
from numpy.random.bit_generator import BitGenerator, SeedSequence
from numpy.typing import _ArrayLikeInt_co
-if sys.version_info >= (3, 8):
- from typing import TypedDict
-else:
- from typing_extensions import TypedDict
-
class _MT19937Internal(TypedDict):
key: ndarray[Any, dtype[uint32]]
pos: int
diff --git a/numpy/random/_pcg64.pyi b/numpy/random/_pcg64.pyi
index 25e2fdde6..4881a987e 100644
--- a/numpy/random/_pcg64.pyi
+++ b/numpy/random/_pcg64.pyi
@@ -1,14 +1,8 @@
-import sys
-from typing import Union
+from typing import Union, TypedDict
from numpy.random.bit_generator import BitGenerator, SeedSequence
from numpy.typing import _ArrayLikeInt_co
-if sys.version_info >= (3, 8):
- from typing import TypedDict
-else:
- from typing_extensions import TypedDict
-
class _PCG64Internal(TypedDict):
state: int
inc: int
diff --git a/numpy/random/_philox.pyi b/numpy/random/_philox.pyi
index f6a5b9b9b..dd1c5e6e9 100644
--- a/numpy/random/_philox.pyi
+++ b/numpy/random/_philox.pyi
@@ -1,15 +1,9 @@
-import sys
-from typing import Any, Union
+from typing import Any, Union, TypedDict
from numpy import dtype, ndarray, uint64
from numpy.random.bit_generator import BitGenerator, SeedSequence
from numpy.typing import _ArrayLikeInt_co
-if sys.version_info >= (3, 8):
- from typing import TypedDict
-else:
- from typing_extensions import TypedDict
-
class _PhiloxInternal(TypedDict):
counter: ndarray[Any, dtype[uint64]]
key: ndarray[Any, dtype[uint64]]
diff --git a/numpy/random/_sfc64.pyi b/numpy/random/_sfc64.pyi
index 72a271c92..94d11a210 100644
--- a/numpy/random/_sfc64.pyi
+++ b/numpy/random/_sfc64.pyi
@@ -1,5 +1,4 @@
-import sys
-from typing import Any, Union
+from typing import Any, Union, TypedDict
from numpy import dtype as dtype
from numpy import ndarray as ndarray
@@ -7,11 +6,6 @@ from numpy import uint64
from numpy.random.bit_generator import BitGenerator, SeedSequence
from numpy.typing import _ArrayLikeInt_co
-if sys.version_info >= (3, 8):
- from typing import TypedDict
-else:
- from typing_extensions import TypedDict
-
class _SFC64Internal(TypedDict):
state: ndarray[Any, dtype[uint64]]
diff --git a/numpy/random/bit_generator.pyi b/numpy/random/bit_generator.pyi
index 5b68dde6c..fa2f1ab12 100644
--- a/numpy/random/bit_generator.pyi
+++ b/numpy/random/bit_generator.pyi
@@ -1,5 +1,4 @@
import abc
-import sys
from threading import Lock
from typing import (
Any,
@@ -16,16 +15,12 @@ from typing import (
TypeVar,
Union,
overload,
+ Literal,
)
from numpy import dtype, ndarray, uint32, uint64
from numpy.typing import _ArrayLikeInt_co, _ShapeLike, _SupportsDType, _UInt32Codes, _UInt64Codes
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
_T = TypeVar("_T")
_DTypeLikeUint32 = Union[
diff --git a/numpy/random/mtrand.pyi b/numpy/random/mtrand.pyi
index 3137b0a95..cbe87a299 100644
--- a/numpy/random/mtrand.pyi
+++ b/numpy/random/mtrand.pyi
@@ -1,5 +1,4 @@
-import sys
-from typing import Any, Callable, Dict, Optional, Tuple, Type, Union, overload
+from typing import Any, Callable, Dict, Optional, Tuple, Type, Union, overload, Literal
from numpy import (
bool_,
@@ -44,11 +43,6 @@ from numpy.typing import (
_UIntCodes,
)
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
_DTypeLikeFloat32 = Union[
dtype[float32],
_SupportsDType[dtype[float32]],
diff --git a/numpy/testing/_private/utils.pyi b/numpy/testing/_private/utils.pyi
index 29915309f..ab5ca8784 100644
--- a/numpy/testing/_private/utils.pyi
+++ b/numpy/testing/_private/utils.pyi
@@ -6,6 +6,7 @@ import warnings
import unittest
import contextlib
from typing import (
+ Literal as L,
Any,
AnyStr,
Callable,
@@ -23,6 +24,8 @@ from typing import (
type_check_only,
TypeVar,
Union,
+ Final,
+ SupportsIndex,
)
from numpy import generic, dtype, number, object_, bool_, _FloatValue
@@ -40,11 +43,6 @@ from unittest.case import (
SkipTest as SkipTest,
)
-if sys.version_info >= (3, 8):
- from typing import Final, SupportsIndex, Literal as L
-else:
- from typing_extensions import Final, SupportsIndex, Literal as L
-
_T = TypeVar("_T")
_ET = TypeVar("_ET", bound=BaseException)
_FT = TypeVar("_FT", bound=Callable[..., Any])
diff --git a/numpy/typing/_ufunc.pyi b/numpy/typing/_ufunc.pyi
index be1e654c2..37e6c008f 100644
--- a/numpy/typing/_ufunc.pyi
+++ b/numpy/typing/_ufunc.pyi
@@ -14,6 +14,8 @@ from typing import (
overload,
Tuple,
TypeVar,
+ Literal,
+ SupportsIndex,
)
from numpy import ufunc, _CastingKind, _OrderKACF
@@ -24,8 +26,6 @@ from ._scalars import _ScalarLike_co
from ._array_like import ArrayLike, _ArrayLikeBool_co, _ArrayLikeInt_co
from ._dtype_like import DTypeLike
-from typing_extensions import Literal, SupportsIndex
-
_T = TypeVar("_T")
_2Tuple = Tuple[_T, _T]
_3Tuple = Tuple[_T, _T, _T]
diff --git a/numpy/typing/tests/data/reveal/arraypad.py b/numpy/typing/tests/data/reveal/arraypad.py
index ba5577ee0..03c03fb4e 100644
--- a/numpy/typing/tests/data/reveal/arraypad.py
+++ b/numpy/typing/tests/data/reveal/arraypad.py
@@ -1,5 +1,4 @@
-from typing import List, Any, Mapping, Tuple
-from typing_extensions import SupportsIndex
+from typing import List, Any, Mapping, Tuple, SupportsIndex
import numpy as np
import numpy.typing as npt