tuples_index_2
error
Tuple index out of range
Detects subscript access on a fixed-length tupleT1, T2, ... parameter where the index is a known integer literal (either an inline int literal or a parameter typed as LiteralN) that falls outside the valid range -len, len-1.
def f(v: tuple[int, str, list[bool]], b: Literal[5]):
v[b] # E — index 5 out of range for 3-element tuple
v[4] # E — index 4 out of range
v[-4] # E — index -4 out of range (valid: -3..-1)
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
tuples_index_2 down per-file or per-path from your editor or
pyproject.toml, or fix the code
so it type-checks. See the Type System rules and
the complete diagnostic reference.
Canonical URL: https://www.basilisk-python.dev/errors/tuples_index_2