Skip to content

Commit 50bad52

Browse files
committed
Add protocol for namespace
Signed-off-by: nstarman <[email protected]>
1 parent caf1011 commit 50bad52

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Diff for: src/array_api_stubs/_draft/_namespace.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
__all__ = ["ArrayAPINamespace"]
2+
3+
from typing import Protocol
4+
5+
6+
class ArrayAPINamespace(Protocol):
7+
"""Protocol for the array API namespace itself."""
8+

Diff for: src/array_api_stubs/_draft/array_object.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
from typing import TYPE_CHECKING
4+
35
from ._types import (
46
array,
57
dtype as Dtype,
@@ -13,6 +15,9 @@
1315
ellipsis,
1416
)
1517

18+
if TYPE_CHECKING:
19+
from ._namespace import ArrayAPINamespace
20+
1621

1722
class _array:
1823
def __init__(self: array) -> None:
@@ -195,7 +200,7 @@ def __and__(self: array, other: Union[int, bool, array], /) -> array:
195200

196201
def __array_namespace__(
197202
self: array, /, *, api_version: Optional[str] = None
198-
) -> Any:
203+
) -> ArrayAPINamespace:
199204
"""
200205
Returns an object that has all the array API functions on it.
201206

0 commit comments

Comments
 (0)