Skip to content

Commit 0baeeb1

Browse files
committed
MAINT: Directly use np.ndarray.__class_getitem__ for the definition of npt.NDArray
1 parent 49f5358 commit 0baeeb1

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

numpy/typing/_generic_alias.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,9 @@ def __getattribute__(self, name: str) -> Any:
205205

206206
ScalarType = TypeVar("ScalarType", bound=np.generic, covariant=True)
207207

208-
if TYPE_CHECKING:
208+
if TYPE_CHECKING or sys.version_info >= (3, 9):
209209
_DType = np.dtype[ScalarType]
210210
NDArray = np.ndarray[Any, np.dtype[ScalarType]]
211-
elif sys.version_info >= (3, 9):
212-
_DType = types.GenericAlias(np.dtype, (ScalarType,))
213-
NDArray = types.GenericAlias(np.ndarray, (Any, _DType))
214211
else:
215212
_DType = _GenericAlias(np.dtype, (ScalarType,))
216213
NDArray = _GenericAlias(np.ndarray, (Any, _DType))

0 commit comments

Comments
 (0)