File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 22
22
23
23
# Build docs
24
24
/src /array_api_typing /_version.py
25
+
26
+ # Mac files
27
+ .DS_Store
Original file line number Diff line number Diff line change 1
1
"""Static typing support for the array API standard."""
2
2
3
- __all__ = ()
3
+ __all__ = [ "HasNamespace" ]
4
4
5
5
from ._version import version as __version__ , version_tuple as __version_tuple__
6
+ from ._namespace import HasNamespace
Original file line number Diff line number Diff line change
1
+ """Static typing support for the array API standard."""
2
+
3
+ __all__ = ["HasNamespace" ]
4
+
5
+ from typing import Protocol
6
+
7
+
8
+ class HasNamespace (Protocol ):
9
+ """Protocol for classes that have an `__array_namespace__` method.
10
+
11
+ This is for type-annotating objects that should
12
+
13
+ Example:
14
+ >>> import array_api_typing as xpt
15
+ >>>
16
+ >>> class MyArray:
17
+ ... def __array_namespace__(self):
18
+ ... return object()
19
+ >>>
20
+ >>> x = MyArray()
21
+ >>> def has_namespace(x: xpt.HasNamespace) -> bool:
22
+ ... return hasattr(x, "__array_namespace__")
23
+ >>> has_namespace(x)
24
+ True
25
+
26
+ """
27
+
28
+ def __array_namespace__ (self ) -> object : ... # noqa: PLW3201
You can’t perform that action at this time.
0 commit comments