Skip to content

Commit 9643256

Browse files
committed
TYP: fix typing errors in numpy._typing
1 parent dc79e3f commit 9643256

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

array_api_compat/numpy/_typing.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,22 @@
33
__all__ = ["Array", "DType", "Device"]
44
_all_ignore = ["np"]
55

6-
from typing import Literal, TYPE_CHECKING
6+
from typing import TYPE_CHECKING, Any, Literal, TypeAlias
77

88
import numpy as np
9-
from numpy import ndarray as Array
109

11-
Device = Literal["cpu"]
10+
Device: TypeAlias = Literal["cpu"]
1211
if TYPE_CHECKING:
1312
# NumPy 1.x on Python 3.10 fails to parse np.dtype[]
14-
DType = np.dtype[
15-
np.intp
16-
| np.int8
17-
| np.int16
18-
| np.int32
19-
| np.int64
20-
| np.uint8
21-
| np.uint16
22-
| np.uint32
23-
| np.uint64
13+
DType: TypeAlias = np.dtype[
14+
np.bool_
15+
| np.integer[Any]
2416
| np.float32
2517
| np.float64
2618
| np.complex64
2719
| np.complex128
28-
| np.bool
2920
]
21+
Array: TypeAlias = np.ndarray[Any, DType]
3022
else:
3123
DType = np.dtype
24+
Array = np.ndarray

0 commit comments

Comments
 (0)