ruff/crates/red_knot_python_semantic/resources/mdtest/subscript/tuple.md
Alex d77480768d
[red-knot] Port type inference tests to new test framework (#13719)
## Summary

Porting infer tests to new markdown tests framework.

Link to the corresponding issue: #13696

---------

Co-authored-by: Carl Meyer <carl@astral.sh>
2024-10-15 11:23:46 -07:00

426 B

Tuple subscripts

Basic

t = (1, 'a', 'b')

a = t[0]
b = t[1]
c = t[-1]
d = t[-2]
e = t[4]        # error: [index-out-of-bounds]
f = t[-4]       # error: [index-out-of-bounds]

reveal_type(a)  # revealed: Literal[1]
reveal_type(b)  # revealed: Literal["a"]
reveal_type(c)  # revealed: Literal["b"]
reveal_type(d)  # revealed: Literal["a"]
reveal_type(e)  # revealed: Unknown
reveal_type(f)  # revealed: Unknown