Consider a nested class which defines the type of an outer class attribute:
class Test():
def __init__(self):
self.foo: list[self.Test2] = []
class Test2():
pass
Using various type checkers this annotation is invalid. For example, PyRight takes the type of the assigned value, which is the generic list [] and not on the type hint list[self.Test2].
(variable) foo: list
If I assign a variable at the outermost scope with bar: list[Test.Test2] = [], it works correctly:
(variable) bar: list[Test2]
How do I make foo take list[Test2] as its type?


