Closed
Description
Example:
from typing import *
A = NamedTuple('A', [('x', int), ('y', str)])
X = 0
Y = 1
a = A()
reveal_type(a[X]) # expected int, but is "Tuple index must be an integer literal"
reveal_type(a[Y]) # expected str, but same error
There's a real-world use case for this: the stats
stdlib module defines constants like ST_MODE
that are supposed to be used as indices into os.stat_result
(which was turned into a NamedTuple in python/typeshed#1103).