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 99 ANY_STRATEGY ,
1010 AnyType ,
1111 BoolTypeQuery ,
12+ CallableArgument ,
1213 CallableType ,
1314 DeletedType ,
15+ EllipsisType ,
1416 ErasedType ,
1517 FunctionLike ,
1618 Instance ,
2022 Parameters ,
2123 ParamSpecType ,
2224 PartialType ,
25+ PlaceholderType ,
2326 ProperType ,
27+ RawExpressionType ,
28+ StarType ,
29+ SyntheticTypeVisitor ,
2430 TupleType ,
2531 Type ,
2632 TypeAliasType ,
2733 TypedDictType ,
34+ TypeList ,
2835 TypeType ,
2936 TypeVarId ,
3037 TypeVarTupleType ,
3138 TypeVarType ,
32- TypeVisitor ,
3339 UnboundType ,
3440 UninhabitedType ,
3541 UnionType ,
@@ -189,7 +195,7 @@ def visit_type_alias_type(self, t: TypeAliasType) -> Type:
189195 return t .copy_modified (args = [arg .accept (self ) for arg in t .args ])
190196
191197
192- class ExpandTypeVisitor (TypeVisitor [Type ]):
198+ class ExpandTypeVisitor (SyntheticTypeVisitor [Type ]):
193199 """Visitor that substitutes type variables with values."""
194200
195201 variables : Mapping [TypeVarId , Type ] # TypeVar id -> TypeVar value
@@ -486,6 +492,24 @@ def visit_type_alias_type(self, t: TypeAliasType) -> Type:
486492 def expand_types (self , types : Iterable [Type ]) -> list [Type ]:
487493 return [t .accept (self ) for t in types ]
488494
495+ def visit_star_type (self , t : StarType ) -> Type :
496+ return t
497+
498+ def visit_type_list (self , t : TypeList ) -> Type :
499+ return t
500+
501+ def visit_callable_argument (self , t : CallableArgument ) -> Type :
502+ return t
503+
504+ def visit_ellipsis_type (self , t : EllipsisType ) -> Type :
505+ return t
506+
507+ def visit_raw_expression_type (self , t : RawExpressionType ) -> Type :
508+ return t
509+
510+ def visit_placeholder_type (self , t : PlaceholderType ) -> Type :
511+ return t
512+
489513
490514def expand_unpack_with_variables (
491515 t : UnpackType , variables : Mapping [TypeVarId , Type ]
Original file line number Diff line number Diff line change @@ -1565,11 +1565,17 @@ def analyze_class(self, defn: ClassDef) -> None:
15651565
15661566 for tvd in tvar_defs :
15671567 if isinstance (tvd , TypeVarType ) and any (
1568- has_placeholder (t ) for t in [tvd .upper_bound , tvd . default ] + tvd .values
1568+ has_placeholder (t ) for t in [tvd .upper_bound ] + tvd .values
15691569 ):
15701570 # Some type variable bounds or values are not ready, we need
15711571 # to re-analyze this class.
15721572 self .defer ()
1573+ if isinstance (tvd , TypeVarLikeType ) and has_placeholder (tvd .default ):
1574+ # Placeholder values in TypeVarLikeTypes may get substituted in.
1575+ # Defer current target until they are ready.
1576+ self .defer ()
1577+ self .mark_incomplete (defn .name , defn )
1578+ return
15731579
15741580 self .analyze_class_keywords (defn )
15751581 bases_result = self .analyze_base_classes (bases )
You can’t perform that action at this time.
0 commit comments