mirror of
https://github.com/astral-sh/ruff
synced 2026-01-09 07:34:06 -05:00
Minor cleanup and consistent formatting of the Markdown-based tests. - Removed lots of unnecessary `a`, `b`, `c`, … variables. - Moved test assertions (`# revealed:` comments) closer to the tested object. - Always separate `# revealed` and `# error` comments from the code by two spaces, according to the discussion [here](https://github.com/astral-sh/ruff/pull/13746/files#r1799385758). This trades readability for consistency in some cases. - Fixed some headings
392 B
392 B
Tuple subscripts
Basic
t = (1, 'a', 'b')
reveal_type(t[0]) # revealed: Literal[1]
reveal_type(t[1]) # revealed: Literal["a"]
reveal_type(t[-1]) # revealed: Literal["b"]
reveal_type(t[-2]) # revealed: Literal["a"]
a = t[4] # error: [index-out-of-bounds]
reveal_type(a) # revealed: Unknown
b = t[-4] # error: [index-out-of-bounds]
reveal_type(b) # revealed: Unknown