Skip to content

Commit 5a05213

Browse files
rgommersnstarman
authored andcommitted
Add a couple of type: ignore comments for __eq__ and __ne__
1 parent 49f2074 commit 5a05213

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/array_api_stubs/_draft/array_object.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,10 @@ def __dlpack_device__(self, /) -> tuple[Enum, int]:
510510
"""
511511
...
512512

513-
def __eq__(self: Self, other: int | float | bool | Self, /) -> Self:
513+
# Note that __eq__ returns an array while `object.__eq__` returns a bool.
514+
# Hence Mypy will complain that this violates the Liskov substitution
515+
# principle - ignore that.
516+
def __eq__(self: Self, other: int | float | bool | Self, /) -> Self: # xtype: ignore
514517
r"""
515518
Computes the truth value of ``self_i == other_i`` for each element of an array instance with the respective element of the array ``other``.
516519
@@ -965,7 +968,8 @@ def __mul__(self: Self, other: int | float | Self, /) -> Self:
965968
"""
966969
...
967970

968-
def __ne__(self: Self, other: int | float | bool | Self, /) -> Self:
971+
# See note above __eq__ method for explanation of the `type: ignore`
972+
def __ne__(self: Self, other: int | float | bool | Self, /) -> Self: # type: ignore
969973
"""
970974
Computes the truth value of ``self_i != other_i`` for each element of an array instance with the respective element of the array ``other``.
971975

0 commit comments

Comments
 (0)