-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
Let's say I have a simple class intended for symbolical computations where == and != evaluate to another expression:
class Expr:
def __eq__(self, other: object) -> 'Expr': ...
def __ne__(self, other: object) -> 'Expr': ...
def __add__(self, other: 'Expr') -> 'Expr': ...
def __sub__(self, other: 'Expr') -> 'Expr': ...
This will result in following errors:
Return type of "__eq__" incompatible with supertype "object"
Return type of "__ne__" incompatible with supertype "object"
As far as I understand Python data model doesn't require rich comparison methods to return bool. Is it Mypy specific requirement or is there something wrong with my class definition?
maxfischer2781, yetone, adewes, 0dminnimda, joooeey and 3 more