5454 GlobalDecl , SuperExpr , DictExpr , CallExpr , RefExpr , OpExpr , UnaryExpr ,
5555 SliceExpr , CastExpr , TypeApplication , Context , SymbolTable ,
5656 SymbolTableNode , BOUND_TVAR , UNBOUND_TVAR , ListComprehension , GeneratorExpr ,
57- FuncExpr , MDEF , FuncBase , Decorator , SetExpr , UndefinedExpr , TypeVarExpr ,
57+ FuncExpr , MDEF , FuncBase , Decorator , SetExpr , TypeVarExpr ,
5858 StrExpr , PrintStmt , ConditionalExpr , PromoteExpr ,
5959 ComparisonExpr , StarExpr , ARG_POS , ARG_NAMED , MroError , type_aliases ,
6060 YieldFromStmt , YieldFromExpr , NamedTupleExpr , NonlocalDecl ,
@@ -821,7 +821,6 @@ def visit_assignment_stmt(self, s: AssignmentStmt) -> None:
821821 if s .type :
822822 s .type = self .anal_type (s .type )
823823 else :
824- s .type = self .infer_type_from_undefined (s .rvalue )
825824 # For simple assignments, allow binding type aliases.
826825 if (s .type is None and len (s .lvalues ) == 1 and
827826 isinstance (s .lvalues [0 ], NameExpr )):
@@ -988,13 +987,6 @@ def check_lvalue_validity(self, node: Node, ctx: Context) -> None:
988987 if isinstance (node , (FuncDef , TypeInfo , TypeVarExpr )):
989988 self .fail ('Invalid assignment target' , ctx )
990989
991- def infer_type_from_undefined (self , rvalue : Node ) -> Type :
992- if isinstance (rvalue , CallExpr ):
993- if isinstance (rvalue .analyzed , UndefinedExpr ):
994- undef = cast (UndefinedExpr , rvalue .analyzed )
995- return undef .type
996- return None
997-
998990 def store_declared_types (self , lvalue : Node , typ : Type ) -> None :
999991 if isinstance (typ , StarType ) and not isinstance (lvalue , StarExpr ):
1000992 self .fail ('Star type only allowed for starred expressions' , lvalue )
@@ -1476,7 +1468,7 @@ def visit_call_expr(self, expr: CallExpr) -> None:
14761468 """Analyze a call expression.
14771469
14781470 Some call expressions are recognized as special forms, including
1479- cast(...), Undefined(...) and Any(...).
1471+ cast(...) and Any(...).
14801472 """
14811473 expr .callee .accept (self )
14821474 if refers_to_fullname (expr .callee , 'typing.cast' ):
@@ -1501,18 +1493,6 @@ def visit_call_expr(self, expr: CallExpr) -> None:
15011493 expr .analyzed = CastExpr (expr .args [0 ], AnyType ())
15021494 expr .analyzed .line = expr .line
15031495 expr .analyzed .accept (self )
1504- elif refers_to_fullname (expr .callee , 'typing.Undefined' ):
1505- # Special form Undefined(...).
1506- if not self .check_fixed_args (expr , 1 , 'Undefined' ):
1507- return
1508- try :
1509- type = expr_to_unanalyzed_type (expr .args [0 ])
1510- except TypeTranslationError :
1511- self .fail ('Argument to Undefined is not a type' , expr )
1512- return
1513- expr .analyzed = UndefinedExpr (type )
1514- expr .analyzed .line = expr .line
1515- expr .analyzed .accept (self )
15161496 elif refers_to_fullname (expr .callee , 'typing._promote' ):
15171497 # Special form _promote(...).
15181498 if not self .check_fixed_args (expr , 1 , '_promote' ):
@@ -1625,9 +1605,6 @@ def visit_cast_expr(self, expr: CastExpr) -> None:
16251605 expr .expr .accept (self )
16261606 expr .type = self .anal_type (expr .type )
16271607
1628- def visit_undefined_expr (self , expr : UndefinedExpr ) -> None :
1629- expr .type = self .anal_type (expr .type )
1630-
16311608 def visit_type_application (self , expr : TypeApplication ) -> None :
16321609 expr .expr .accept (self )
16331610 for i in range (len (expr .types )):
@@ -2006,9 +1983,6 @@ def visit_assignment_stmt(self, s: AssignmentStmt) -> None:
20061983 self .analyze (s .type )
20071984 super ().visit_assignment_stmt (s )
20081985
2009- def visit_undefined_expr (self , e : UndefinedExpr ) -> None :
2010- self .analyze (e .type )
2011-
20121986 def visit_cast_expr (self , e : CastExpr ) -> None :
20131987 self .analyze (e .type )
20141988 super ().visit_cast_expr (e )
0 commit comments