diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index efc51fe257ae..10409039f17b 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -121,8 +121,12 @@ class object: # Overriding them in subclasses has different semantics, even if the override has an identical signature. def __setattr__(self, name: str, value: Any, /) -> None: ... def __delattr__(self, name: str, /) -> None: ... - def __eq__(self, value: object, /) -> bool: ... - def __ne__(self, value: object, /) -> bool: ... + # Using 'Any' rather than 'object' for the argument because + # classes may want to restrict the type. + # Using 'Any | bool' rather than 'bool' for the return type because + # classes may want to return a wider type (e.g. numpy array) + def __eq__(self, value: Any, /) -> Any | bool: ... # noqa: Y032 + def __ne__(self, value: Any, /) -> Any | bool: ... # noqa: Y032 def __str__(self) -> str: ... # noqa: Y029 def __repr__(self) -> str: ... # noqa: Y029 def __hash__(self) -> int: ...