Skip to content

Commit c4d3179

Browse files
committed
refactor Array as a Protocol
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
1 parent e72b3ca commit c4d3179

File tree

3 files changed

+137
-85
lines changed

3 files changed

+137
-85
lines changed

src/array_api_stubs/_draft/_types.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from dataclasses import dataclass
1010
from typing import (
11+
TYPE_CHECKING,
1112
Any,
1213
List,
1314
Literal,
@@ -20,9 +21,14 @@
2021
)
2122
from enum import Enum
2223

23-
array = TypeVar("array")
24+
25+
if TYPE_CHECKING:
26+
from .array_object import Array
27+
from .data_types import DType
28+
29+
array = TypeVar("array", bound="Array")
2430
device = TypeVar("device")
25-
dtype = TypeVar("dtype")
31+
dtype = TypeVar("dtype", bound="DType")
2632
SupportsDLPack = TypeVar("SupportsDLPack")
2733
SupportsBufferProtocol = TypeVar("SupportsBufferProtocol")
2834
PyCapsule = TypeVar("PyCapsule")
@@ -34,6 +40,7 @@
3440
@dataclass
3541
class finfo_object:
3642
"""Dataclass returned by `finfo`."""
43+
3744
bits: int
3845
eps: float
3946
max: float
@@ -44,6 +51,7 @@ class finfo_object:
4451
@dataclass
4552
class iinfo_object:
4653
"""Dataclass returned by `iinfo`."""
54+
4755
bits: int
4856
max: int
4957
min: int
@@ -60,6 +68,7 @@ def __len__(self, /) -> int:
6068
...
6169

6270

71+
6372
__all__ = [
6473
"Any",
6574
"List",

0 commit comments

Comments
 (0)