You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
could this be fixed by updating the __eq__ from object to only allow Self:
def__eq__(self, __value: Self) ->bool: ...
because currently since it takes object no subtypes can override it with something more specific. your example currently doesnt work for that reason:
classSupportsEq(Protocol[T]):
@overridedef__eq__(self, other: T) ->bool: ... # error: error: Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"
but if object's __eq__ used the Self type, then a subtype could just do this and there'd be no issue:
This issue is that operators tend to be implemented like:
Ideal analysis would be:
Solution:
you annotate the compatible types, and they become
object
in the implementation:Although, every
__eq__
that exists in the world today isother: object
, so we won't get much benefit :(We might need to examine the implementation to get a nice type. (#453)
The text was updated successfully, but these errors were encountered: