Skip to content

Commit 6950944

Browse files
committed
Add a couple of type: ignore comments for __eq__ and __ne__
1 parent 0e24933 commit 6950944

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
@@ -392,7 +392,10 @@ def __dlpack_device__(self, /) -> tuple[Enum, int]:
392392
"""
393393
...
394394

395-
def __eq__(self: Self, other: int | float | bool | Self, /) -> Self:
395+
# Note that __eq__ returns an array while `object.__eq__` returns a bool.
396+
# Hence Mypy will complain that this violates the Liskov substitution
397+
# principle - ignore that.
398+
def __eq__(self: Self, other: int | float | bool | Self, /) -> Self: # xtype: ignore
396399
r"""
397400
Computes the truth value of ``self_i == other_i`` for each element of an array instance with the respective element of the array ``other``.
398401
@@ -799,7 +802,8 @@ def __mul__(self: Self, other: int | float | Self, /) -> Self:
799802
"""
800803
...
801804

802-
def __ne__(self: Self, other: int | float | bool | Self, /) -> Self:
805+
# See note above __eq__ method for explanation of the `type: ignore`
806+
def __ne__(self: Self, other: int | float | bool | Self, /) -> Self: # type: ignore
803807
"""
804808
Computes the truth value of ``self_i != other_i`` for each element of an array instance with the respective element of the array ``other``.
805809

0 commit comments

Comments
 (0)