Skip to content

Commit

Permalink
MAINT: Directly use np.ndarray.__class_getitem__ for the definition…
Browse files Browse the repository at this point in the history
… of `npt.NDArray`
  • Loading branch information
BvB93 committed Sep 15, 2021
1 parent 49f5358 commit 0baeeb1
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions numpy/typing/_generic_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,9 @@ def __getattribute__(self, name: str) -> Any:

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

if TYPE_CHECKING:
if TYPE_CHECKING or sys.version_info >= (3, 9):
_DType = np.dtype[ScalarType]
NDArray = np.ndarray[Any, np.dtype[ScalarType]]
elif sys.version_info >= (3, 9):
_DType = types.GenericAlias(np.dtype, (ScalarType,))
NDArray = types.GenericAlias(np.ndarray, (Any, _DType))
else:
_DType = _GenericAlias(np.dtype, (ScalarType,))
NDArray = _GenericAlias(np.ndarray, (Any, _DType))

0 comments on commit 0baeeb1

Please sign in to comment.