11from __future__ import annotations
22
33from types import ModuleType as Namespace
4- from typing import Any , Protocol , TypeAlias , TypeVar
4+ from typing import Any , Protocol , TypeAlias , TypedDict , TypeVar
55
66_T_co = TypeVar ("_T_co" , covariant = True )
77
8+
89class NestedSequence (Protocol [_T_co ]):
910 def __getitem__ (self , key : int , / ) -> _T_co | NestedSequence [_T_co ]: ...
1011 def __len__ (self , / ) -> int : ...
@@ -19,6 +20,16 @@ class HasShape(Protocol[_T_co]):
1920 def shape (self , / ) -> _T_co : ...
2021
2122
23+ Capabilities = TypedDict (
24+ "Capabilities" ,
25+ {
26+ "boolean indexing" : bool ,
27+ "data-dependent shapes" : bool ,
28+ "max dimensions" : int ,
29+ },
30+ )
31+
32+
2233SupportsBufferProtocol : TypeAlias = Any
2334Array : TypeAlias = Any
2435Device : TypeAlias = Any
@@ -27,12 +38,13 @@ def shape(self, /) -> _T_co: ...
2738
2839__all__ = [
2940 "Array" ,
30- "SupportsArrayNamespace " ,
41+ "Capabilities " ,
3142 "DType" ,
3243 "Device" ,
3344 "HasShape" ,
3445 "Namespace" ,
3546 "NestedSequence" ,
47+ "SupportsArrayNamespace" ,
3648 "SupportsBufferProtocol" ,
3749]
3850
0 commit comments