@@ -748,7 +748,7 @@ a: MyA = A(None, 10)
748
748
reveal_type(a.a) # N: Revealed type is "Union[builtins.int, None]"
749
749
[builtins fixtures/tuple.pyi]
750
750
751
- [case testTypeVarDefaultAliasesTypeAliasType ]
751
+ [case testTypeVarConstraintsDefaultAliasesTypeAliasType ]
752
752
from typing_extensions import TypeAliasType, TypeVar
753
753
754
754
K = TypeAliasType("K", int)
@@ -759,7 +759,7 @@ T2 = TypeVar("T2", str, K, default=V)
759
759
T3 = TypeVar("T3", str, L, default=L)
760
760
[builtins fixtures/tuple.pyi]
761
761
762
- [case testTypeVarDefaultAliasesImplicitAlias ]
762
+ [case testTypeVarConstraintsDefaultAliasesImplicitAlias ]
763
763
from typing_extensions import TypeVar
764
764
765
765
K = int
@@ -770,7 +770,7 @@ T2 = TypeVar("T2", str, K, default=V)
770
770
T3 = TypeVar("T3", str, L, default=L)
771
771
[builtins fixtures/tuple.pyi]
772
772
773
- [case testTypeVarDefaultAliasesExplicitAlias ]
773
+ [case testTypeVarConstraintsDefaultAliasesExplicitAlias ]
774
774
from typing_extensions import TypeAlias, TypeVar
775
775
776
776
K: TypeAlias = int
@@ -780,3 +780,40 @@ T1 = TypeVar("T1", str, K, default=K)
780
780
T2 = TypeVar("T2", str, K, default=V)
781
781
T3 = TypeVar("T3", str, L, default=L)
782
782
[builtins fixtures/tuple.pyi]
783
+
784
+ [case testTypeVarConstraintsDefaultSpecialTypes]
785
+ from typing import NamedTuple
786
+ from typing_extensions import TypedDict, TypeVar
787
+
788
+ class TD(TypedDict):
789
+ foo: str
790
+
791
+ class NT(NamedTuple):
792
+ foo: str
793
+
794
+ T1 = TypeVar("T1", str, TD, default=TD)
795
+ T2 = TypeVar("T2", str, NT, default=NT)
796
+ [builtins fixtures/tuple.pyi]
797
+
798
+ [case testTypeVarConstraintsDefaultSpecialTypesGeneric]
799
+ from typing import Generic, NamedTuple
800
+ from typing_extensions import TypedDict, TypeVar
801
+
802
+ T = TypeVar("T")
803
+
804
+ class TD(TypedDict, Generic[T]):
805
+ foo: T
806
+ class TD2(TD[int]): pass
807
+ class TD3(TD[int]):
808
+ bar: str
809
+
810
+ class NT(NamedTuple, Generic[T]):
811
+ foo: T
812
+ class NT2(NT[int]): pass
813
+
814
+ T1 = TypeVar("T1", str, TD[int], default=TD[int])
815
+ T2 = TypeVar("T2", str, NT[int], default=NT[int])
816
+ T3 = TypeVar("T3", str, TD2, default=TD[int])
817
+ T4 = TypeVar("T4", str, TD3, default=TD[int]) # E: TypeVar default must be one of the constraint types
818
+ T5 = TypeVar("T5", str, NT2, default=NT[int]) # E: TypeVar default must be one of the constraint types
819
+ [builtins fixtures/tuple.pyi]
0 commit comments