Skip to content

Commit 29b7a69

Browse files
committed
Use better type definitions for the array API custom types
1 parent 5780a9b commit 29b7a69

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

numpy/_array_api/_types.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
from . import (Array, int8, int16, int32, int64, uint8, uint16, uint32,
1515
uint64, float32, float64)
1616

17-
Array = ndarray
18-
Device = TypeVar('device')
19-
Dtype = Literal[int8, int16, int32, int64, uint8, uint16,
20-
uint32, uint64, float32, float64]
21-
SupportsDLPack = TypeVar('SupportsDLPack')
22-
SupportsBufferProtocol = TypeVar('SupportsBufferProtocol')
23-
PyCapsule = TypeVar('PyCapsule')
17+
# This should really be recursive, but that isn't supported yet. See the
18+
# similar comment in numpy/typing/_array_like.py
19+
NestedSequence = Sequence[Sequence[Any]]
20+
21+
Device = Any
22+
Dtype = Type[Union[[int8, int16, int32, int64, uint8, uint16,
23+
uint32, uint64, float32, float64]]]
24+
SupportsDLPack = Any
25+
SupportsBufferProtocol = Any
26+
PyCapsule = Any

0 commit comments

Comments
 (0)