@@ -2182,7 +2182,6 @@ def process_type_annotation(self, s: AssignmentStmt) -> None:
2182
2182
analyzed = self .anal_type (s .type , allow_tuple_literal = allow_tuple_literal )
2183
2183
# Don't store not ready types (including placeholders).
2184
2184
if analyzed is None or has_placeholder (analyzed ):
2185
- self .defer ()
2186
2185
return
2187
2186
s .type = analyzed
2188
2187
if (self .type and self .type .is_protocol and isinstance (lvalue , NameExpr ) and
@@ -3565,7 +3564,6 @@ def analyze_type_application_args(self, expr: IndexExpr) -> Optional[List[Type]]
3565
3564
analyzed = self .anal_type (typearg , allow_unbound_tvars = True ,
3566
3565
allow_placeholder = True )
3567
3566
if analyzed is None :
3568
- self .defer ()
3569
3567
return None
3570
3568
types .append (analyzed )
3571
3569
return types
@@ -4507,9 +4505,23 @@ def anal_type(self,
4507
4505
third_pass : bool = False ) -> Optional [Type ]:
4508
4506
"""Semantically analyze a type.
4509
4507
4510
- Return None only if some part of the type couldn't be bound *and* it referred
4511
- to an incomplete namespace. In case of other errors, report an error message
4512
- and return AnyType.
4508
+ Args:
4509
+ typ: Type to analyze (if already analyzed, this is a no-op)
4510
+ allow_placeholder: If True, may return PlaceholderType if
4511
+ encountering an incomplete definition
4512
+ third_pass: Unused; only for compatibility with old semantic
4513
+ analyzer
4514
+
4515
+ Return None only if some part of the type couldn't be bound *and* it
4516
+ referred to an incomplete namespace or definition. In this case also
4517
+ defer as needed. During a final iteration this won't return None;
4518
+ instead report an error if the type can't be analyzed and return
4519
+ AnyType.
4520
+
4521
+ In case of other errors, report an error message and return AnyType.
4522
+
4523
+ NOTE: The caller shouldn't defer even if this returns None or a
4524
+ placeholder type.
4513
4525
"""
4514
4526
a = self .type_analyzer (tvar_scope = tvar_scope ,
4515
4527
allow_unbound_tvars = allow_unbound_tvars ,
0 commit comments