I have the following function:
def __eq__(self, other: object) -> Union[bool, NotImplemented]:
try:
for attr in ["name", "variable_type"]:
if getattr(self, attr) != getattr(other, attr):
return False
return True
except AttributeError:
return NotImplemented # Expression has type "Any"
I'm running mypy, and it's telling me that NotImplemented is of type "Any", which it obviously doesn't like.
Is there any better type I can use to remove this error? Or should I just put a type: ignore in and move on? (In addition, is my use of NotImplemented in the return type correct?)