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
testcase.py:7: error: Tuple index out of range [misc]
return values[0] + values[2] + values[1]
^
There is no need to report an error here, since the tuple will always have a third element if the second return statement is reached.
I think mypy could filter the Union options using the len(values) == 2 guard, which is always true for Tuple[str, str] and always false for Tuple[str, str, str].
The example in this comment from @abey79 looks equivalent to this issue, but the test case for #8733 itself also includes a List, so it has to deal with runtime length rather than the static length of a tuple type.
The text was updated successfully, but these errors were encountered:
When mypy 0.782 checks the following code:
It reports:
There is no need to report an error here, since the tuple will always have a third element if the second
return
statement is reached.I think mypy could filter the
Union
options using thelen(values) == 2
guard, which is always true forTuple[str, str]
and always false forTuple[str, str, str]
.The example in this comment from @abey79 looks equivalent to this issue, but the test case for #8733 itself also includes a
List
, so it has to deal with runtime length rather than the static length of a tuple type.The text was updated successfully, but these errors were encountered: