@@ -8595,17 +8595,20 @@ import enum as __enum
8595
8595
class C(__enum.Flag): ...
8596
8596
8597
8597
[case testNameManglingAnnotationsPast]
8598
+ from typing import Generic, TypeVar
8598
8599
8599
- class A:
8600
- __x: int
8600
+ __T = TypeVar("__T")
8601
+
8602
+ class A(Generic[__T]):
8603
+ __x: __T # E: Name "_A__T" is not defined
8601
8604
8602
8605
__y = int
8603
8606
class __B:
8604
- def f1(self, a: A) -> __y: # E: Name "_B__y" is not defined
8605
- a.__x # E: "A" has no attribute "_B__x"; maybe "_A__x"?
8607
+ def f1(self, a: A[int] ) -> __y: # E: Name "_B__y" is not defined
8608
+ a.__x # E: "A[int] " has no attribute "_B__x"; maybe "_A__x"?
8606
8609
8607
8610
def f2(self, a: A) -> "__y":
8608
- a.__x # E: "A" has no attribute "_B__x"; maybe "_A__x"?
8611
+ a.__x # E: "A[Any] " has no attribute "_B__x"; maybe "_A__x"?
8609
8612
return 1
8610
8613
8611
8614
class C:
@@ -8623,18 +8626,20 @@ reveal_type(C().b2) # N: Revealed type is "__main__.__B"
8623
8626
8624
8627
[case testNameManglingAnnotationsFuture]
8625
8628
from __future__ import annotations
8629
+ from typing import Generic, TypeVar
8626
8630
8627
- class A:
8628
- __x: int
8631
+ __T = TypeVar("__T")
8632
+ class A(Generic[__T]):
8633
+ __x: __T
8629
8634
8630
8635
__y = int
8631
8636
class __B:
8632
- def f1(self, a: A) -> __y:
8633
- a.__x # E: "A" has no attribute "_B__x"; maybe "_A__x"?
8637
+ def f1(self, a: A[int] ) -> __y:
8638
+ a.__x # E: "A[int] " has no attribute "_B__x"; maybe "_A__x"?
8634
8639
return 1
8635
8640
8636
8641
def f2(self, a: A) -> "__y":
8637
- a.__x # E: "A" has no attribute "_B__x"; maybe "_A__x"?
8642
+ a.__x # E: "A[Any] " has no attribute "_B__x"; maybe "_A__x"?
8638
8643
return 1
8639
8644
8640
8645
class C:
0 commit comments