Overriding an overloaded method that returns a value of a Union type #10799
Labels
bug
mypy got something wrong
topic-inheritance
Inheritance and incompatible overrides
topic-overloads
Bug Report
Mypy raises an error when overriding an overloaded method that returns a value of a Union type, even though the original and overridden methods have the same signature.
To Reproduce
Expected Behavior
Because the implementations of
Base.A
andDerived.A
have exactly the same signature indeed, I want this to pass the type checking.Actual Behavior
An error
Signature of "A" incompatible with supertype "Base"
is raised at the definition ofDerived.A
.Some additional observations are:
Base.A
andDerived.A
are implemented as static methods, adding @overload-decorated methods to the subclass does not resolve the errorYour Environment
The text was updated successfully, but these errors were encountered: