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 ,
@@ -205,7 +211,7 @@ def visit_type_alias_type(self, t: TypeAliasType) -> Type:
205
211
return t .copy_modified (args = [arg .accept (self ) for arg in t .args ])
206
212
207
213
208
- class ExpandTypeVisitor (TypeVisitor [Type ]):
214
+ class ExpandTypeVisitor (SyntheticTypeVisitor [Type ]):
209
215
"""Visitor that substitutes type variables with values."""
210
216
211
217
variables : Mapping [TypeVarId , Type ] # TypeVar id -> TypeVar value
@@ -523,6 +529,24 @@ def visit_type_alias_type(self, t: TypeAliasType) -> Type:
523
529
def expand_types (self , types : Iterable [Type ]) -> list [Type ]:
524
530
return [t .accept (self ) for t in types ]
525
531
532
+ def visit_star_type (self , t : StarType ) -> Type :
533
+ return t
534
+
535
+ def visit_type_list (self , t : TypeList ) -> Type :
536
+ return t
537
+
538
+ def visit_callable_argument (self , t : CallableArgument ) -> Type :
539
+ return t
540
+
541
+ def visit_ellipsis_type (self , t : EllipsisType ) -> Type :
542
+ return t
543
+
544
+ def visit_raw_expression_type (self , t : RawExpressionType ) -> Type :
545
+ return t
546
+
547
+ def visit_placeholder_type (self , t : PlaceholderType ) -> Type :
548
+ return t
549
+
526
550
527
551
def expand_unpack_with_variables (
528
552
t : UnpackType , variables : Mapping [TypeVarId , Type ]
Original file line number Diff line number Diff line change @@ -1600,11 +1600,17 @@ def analyze_class(self, defn: ClassDef) -> None:
1600
1600
1601
1601
for tvd in tvar_defs :
1602
1602
if isinstance (tvd , TypeVarType ) and any (
1603
- has_placeholder (t ) for t in [tvd .upper_bound , tvd . default ] + tvd .values
1603
+ has_placeholder (t ) for t in [tvd .upper_bound ] + tvd .values
1604
1604
):
1605
1605
# Some type variable bounds or values are not ready, we need
1606
1606
# to re-analyze this class.
1607
1607
self .defer ()
1608
+ if isinstance (tvd , TypeVarLikeType ) and has_placeholder (tvd .default ):
1609
+ # Placeholder values in TypeVarLikeTypes may get substituted in.
1610
+ # Defer current target until they are ready.
1611
+ self .defer ()
1612
+ self .mark_incomplete (defn .name , defn )
1613
+ return
1608
1614
1609
1615
self .analyze_class_keywords (defn )
1610
1616
bases_result = self .analyze_base_classes (bases )
You can’t perform that action at this time.
0 commit comments