I am trying to make mypy happy with my type annotations. Here is minimal example:
class FooInterface:
x: int
class FooWithAttribute(FooInterface):
x: int = 0
class FooWithProperty(FooInterface):
@property
def x(self) -> int:
return 0
To my human understanding everything is fine: both FooWithAttribute().x and FooWithProperty().x will return 0 which is int, no type errors. However mypy complains:
error: Signature of "x" incompatible with supertype "FooInterface"
Is there a way to tell mypy that everything is OK? Right now the only way I found is annotating x: typing.Any in FooInterface which wastes the information that x is int.