Skip to content

Commit f77be13

Browse files
committed
feat: HasDevice
Signed-off-by: nstarman <[email protected]>
1 parent 624c3ba commit f77be13

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ ignore = [
130130
"ISC001", # Conflicts with formatter
131131
"PLW1641", # Object does not implement `__hash__` method
132132
"PYI041", # Use `float` instead of `int | float`
133+
"TD002", # Missing author in TODO
134+
"TD003", # Missing issue link for this TOOD
133135
]
134136

135137
[tool.ruff.lint.pylint]

src/array_api_typing/_array.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,20 @@ def dtype(self) -> DType_co:
6262
...
6363

6464

65+
class HasDevice(Protocol):
66+
"""Protocol for array classes that have a device attribute."""
67+
68+
@property
69+
def device(self) -> object: # TODO: more specific type
70+
"""Hardware device the array data resides on."""
71+
...
72+
73+
6574
@docstring_setter(**_array_docstrings)
6675
class Array(
6776
# ------ Attributes -------
6877
HasDType[DType_co],
78+
HasDevice,
6979
# ------ Methods -------
7080
HasArrayNamespace[NS_co],
7181
op.CanPosSelf,

0 commit comments

Comments
 (0)