Given the following class, how should I annotate __eq__
?
class Foo(object):
def __init__(self, bar):
self.bar = bar
def __eq__(self, other):
return Foo.bar == other.bar
Using __eq__(self, other: Foo) -> bool
makes mypy
error with:
Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"
and using __eq__(self, other: object) -> bool
makes mypy
error with:
"object" has no attribute "bar"
What should I do?