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
@@ -507,6 +513,24 @@ def visit_type_alias_type(self, t: TypeAliasType) -> Type:
507513 def expand_types (self , types : Iterable [Type ]) -> list [Type ]:
508514 return [t .accept (self ) for t in types ]
509515
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+
510534
511535def expand_unpack_with_variables (
512536 t : UnpackType , variables : Mapping [TypeVarId , Type ]
Original file line number Diff line number Diff line change @@ -1593,11 +1593,17 @@ def analyze_class(self, defn: ClassDef) -> None:
15931593
15941594 for tvd in tvar_defs :
15951595 if isinstance (tvd , TypeVarType ) and any (
1596- has_placeholder (t ) for t in [tvd .upper_bound , tvd . default ] + tvd .values
1596+ has_placeholder (t ) for t in [tvd .upper_bound ] + tvd .values
15971597 ):
15981598 # Some type variable bounds or values are not ready, we need
15991599 # to re-analyze this class.
16001600 self .defer ()
1601+ if isinstance (tvd , TypeVarLikeType ) and has_placeholder (tvd .default ):
1602+ # Placeholder values in TypeVarLikeTypes may get substituted in.
1603+ # Defer current target until they are ready.
1604+ self .defer ()
1605+ self .mark_incomplete (defn .name , defn )
1606+ return
16011607
16021608 self .analyze_class_keywords (defn )
16031609 bases_result = self .analyze_base_classes (bases )
You can’t perform that action at this time.
0 commit comments