Weird behaviour with TypeVar and conditional expression containing isinstance() #9195
Labels
bug
mypy got something wrong
topic-ternary-expression
a if b else c
topic-type-narrowing
Conditional type narrowing / binder
topic-type-variables
Lets consider this source code:
I am using Python 3.8.3 and mypy 0.782. Depending on
TypeVar
definition I get following results:This means the conditional expression containing
isinstance()
in functionget_name_bad()
does trigger error while normal if-block withisinstance()
fromget_name_good()
doesnt. All of this is happening only with fixed-length tuple inTypeVar
and not with variable length tuple.I would expect there is no difference between
Tuple[N, N]
andTuple[N, ...]
when checking the type viaisinstance()
in conditional expression.The text was updated successfully, but these errors were encountered: