Closed
Description
Consider this code:
class C:
T = "class"
type Alias3[T] = (T for _ in (1,))
type Alias5[T] = [T for _ in (1,)]
print(list(C.Alias3.__value__))
print(C.Alias5.__value__)
On current main it produces:
[T]
['class']
So if you use a genexp, you get the T
type parameter, but if you use a listcomp, you get the class variable. I think the genexp behavior is right; the comprehension should never see the class scope.
Found this while looking into #109118. Filing this separately as the symptom is different, but I suspect we'll have to solve both simultaneously. cc @carljm for PEP 709.