File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change 9
9
ANY_STRATEGY ,
10
10
AnyType ,
11
11
BoolTypeQuery ,
12
+ CallableArgument ,
12
13
CallableType ,
13
14
DeletedType ,
15
+ EllipsisType ,
14
16
ErasedType ,
15
17
FunctionLike ,
16
18
Instance ,
20
22
Parameters ,
21
23
ParamSpecType ,
22
24
PartialType ,
25
+ PlaceholderType ,
23
26
ProperType ,
27
+ RawExpressionType ,
28
+ StarType ,
29
+ SyntheticTypeVisitor ,
24
30
TupleType ,
25
31
Type ,
26
32
TypeAliasType ,
27
33
TypedDictType ,
34
+ TypeList ,
28
35
TypeType ,
29
36
TypeVarId ,
30
37
TypeVarTupleType ,
31
38
TypeVarType ,
32
- TypeVisitor ,
33
39
UnboundType ,
34
40
UninhabitedType ,
35
41
UnionType ,
@@ -189,7 +195,7 @@ def visit_type_alias_type(self, t: TypeAliasType) -> Type:
189
195
return t .copy_modified (args = [arg .accept (self ) for arg in t .args ])
190
196
191
197
192
- class ExpandTypeVisitor (TypeVisitor [Type ]):
198
+ class ExpandTypeVisitor (SyntheticTypeVisitor [Type ]):
193
199
"""Visitor that substitutes type variables with values."""
194
200
195
201
variables : Mapping [TypeVarId , Type ] # TypeVar id -> TypeVar value
@@ -507,6 +513,24 @@ def visit_type_alias_type(self, t: TypeAliasType) -> Type:
507
513
def expand_types (self , types : Iterable [Type ]) -> list [Type ]:
508
514
return [t .accept (self ) for t in types ]
509
515
516
+ def visit_star_type (self , t : StarType ) -> Type :
517
+ return t
518
+
519
+ def visit_type_list (self , t : TypeList ) -> Type :
520
+ return t
521
+
522
+ def visit_callable_argument (self , t : CallableArgument ) -> Type :
523
+ return t
524
+
525
+ def visit_ellipsis_type (self , t : EllipsisType ) -> Type :
526
+ return t
527
+
528
+ def visit_raw_expression_type (self , t : RawExpressionType ) -> Type :
529
+ return t
530
+
531
+ def visit_placeholder_type (self , t : PlaceholderType ) -> Type :
532
+ return t
533
+
510
534
511
535
def expand_unpack_with_variables (
512
536
t : UnpackType , variables : Mapping [TypeVarId , Type ]
Original file line number Diff line number Diff line change @@ -1598,11 +1598,17 @@ def analyze_class(self, defn: ClassDef) -> None:
1598
1598
1599
1599
for tvd in tvar_defs :
1600
1600
if isinstance (tvd , TypeVarType ) and any (
1601
- has_placeholder (t ) for t in [tvd .upper_bound , tvd . default ] + tvd .values
1601
+ has_placeholder (t ) for t in [tvd .upper_bound ] + tvd .values
1602
1602
):
1603
1603
# Some type variable bounds or values are not ready, we need
1604
1604
# to re-analyze this class.
1605
1605
self .defer ()
1606
+ if isinstance (tvd , TypeVarLikeType ) and has_placeholder (tvd .default ):
1607
+ # Placeholder values in TypeVarLikeTypes may get substituted in.
1608
+ # Defer current target until they are ready.
1609
+ self .defer ()
1610
+ self .mark_incomplete (defn .name , defn )
1611
+ return
1606
1612
1607
1613
self .analyze_class_keywords (defn )
1608
1614
bases_result = self .analyze_base_classes (bases )
You can’t perform that action at this time.
0 commit comments