Skip to content

Commit 6e8c89d

Browse files
committed
Add device protocol to fix type ignore
Signed-off-by: nstarman <[email protected]>
1 parent 19afbae commit 6e8c89d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/array_api_stubs/_draft/_types.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,16 @@
5252
from .array_object import Array
5353
from .data_types import DType
5454

55+
56+
class Device(Protocol):
57+
"""Protocol for device objects."""
58+
59+
def __eq__(self, value: Any) -> bool:
60+
...
61+
62+
5563
array = TypeVar("array", bound="Array")
56-
device = TypeVar("device")
64+
device = TypeVar("device", bound=Device)
5765
dtype = TypeVar("dtype", bound="DType")
5866
SupportsDLPack = TypeVar("SupportsDLPack")
5967
SupportsBufferProtocol = TypeVar("SupportsBufferProtocol")

src/array_api_stubs/_draft/array_object.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import TYPE_CHECKING, Protocol, TypeVar
66
from enum import Enum
77
from .data_types import DType
8-
from ._types import device as Device
8+
from ._types import Device
99

1010
if TYPE_CHECKING:
1111
from ._types import (
@@ -36,7 +36,7 @@ def dtype(self) -> DType:
3636
...
3737

3838
@property
39-
def device(self) -> "Device": # type: ignore[type-var]
39+
def device(self) -> Device:
4040
"""
4141
Hardware device the array data resides on.
4242

0 commit comments

Comments
 (0)