False positive error on a generic type-preserving function if returning from within an isinstance
branch
#18658
Labels
bug
mypy got something wrong
Bug Report
Mypy does not make deductions of the type of type parameter based on
isinstance
branches within the function. For example, in a function that takes an argument of any type and returns a value of that same type, it mypy raises an error about the type of the return argument not being correct if returning from within anisinstance
branch.To Reproduce
HERE IN THE PLAYGROUND
Of course this example does not make much sense by itself, the idea would be to do some type-preserving transformations inside the
isinstance
branchExpected Behavior
I'd expect this code annotations to validate without raising any error.
Actual Behavior
Raises the following error
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: