You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As part of this validation, mypy reports errors when there is overlap between two overloads that return different return types. The following test case shows four such examples. Mypy properly reports the error in three of the four cases, but it misses the case where there is an implied subtype relationship, as between int and float.
# pyright: strictfromtypingimportLiteral, Union, overloadclassParent: ...
classChild(Parent): ...
# Test 1: Literal subtype@overloaddeffoo1(x: Literal[3]) ->int: ...
@overloaddeffoo1(x: int) ->str: ...
# Test 2: Subclass subtype@overloaddeffoo2(x: Child) ->str: ...
@overloaddeffoo2(x: Parent) ->int: ...
# Test 3: Implicit subtype@overloaddeffoo3(x: int) ->str: ... # Mypy does not report error here@overloaddeffoo3(x: float) ->int: ...
# Test 4: Union subtype@overloaddeffoo4(x: int) ->str: ...
@overloaddeffoo4(x: Union[int, str]) ->int: ...
The text was updated successfully, but these errors were encountered:
I'm working to make pyright's overload validation work consistently with mypy's.
Mypy's overload validation behavior is spec'ed here: python/typing#253 (comment)
As part of this validation, mypy reports errors when there is overlap between two overloads that return different return types. The following test case shows four such examples. Mypy properly reports the error in three of the four cases, but it misses the case where there is an implied subtype relationship, as between
int
andfloat
.The text was updated successfully, but these errors were encountered: