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
mypy incorrectly infers a Tuple index out of range error when discriminating between two tuples in a union via their length, even when using a literal int when analyzing the length of the tuple instance.
To Reproduce
fromtypingimportTuple, UnionTuple3=Tuple[str, str, str]
Tuple4=Tuple[str, str, str, str]
Tuples=Union[Tuple3, Tuple4]
deftest_tuples(my_tuple: Tuples) ->None:
iflen(my_tuple) >=4:
my_tuple[3] # misc - Tuple index out of range
Expected Behavior
Not returning an "index out of range" error, when it is clearly impossible for it to be the case.
Actual Behavior
mypy infers misc - Tuple index out of range
Your Environment
Mypy version used: 0.950 (compiled: yes)
Mypy command-line flags: N/A
Mypy configuration options from mypy.ini (and other config files): N/A
Python version used: 3.10
Operating system and version: pop-os 22.04
The text was updated successfully, but these errors were encountered:
Bug Report
mypy incorrectly infers a
Tuple index out of range
error when discriminating between two tuples in a union via their length, even when using a literalint
when analyzing the length of the tuple instance.To Reproduce
Expected Behavior
Not returning an "index out of range" error, when it is clearly impossible for it to be the case.
Actual Behavior
mypy infers
misc - Tuple index out of range
Your Environment
mypy.ini
(and other config files): N/AThe text was updated successfully, but these errors were encountered: