@@ -3283,7 +3283,7 @@ def visit_assignment_stmt(self, s: AssignmentStmt) -> None:
32833283 # as X | Y.
32843284 if not (s .is_alias_def and self .is_stub ):
32853285 with self .enter_final_context (s .is_final_def ):
3286- self .check_assignment (s .lvalues [- 1 ], s .rvalue , s .type is None , s . new_syntax )
3286+ self .check_assignment (s .lvalues [- 1 ], s .rvalue , s .type is None )
32873287
32883288 if s .is_alias_def :
32893289 self .check_type_alias_rvalue (s )
@@ -3331,11 +3331,7 @@ def check_type_alias_rvalue(self, s: AssignmentStmt) -> None:
33313331 self .store_type (s .lvalues [- 1 ], alias_type )
33323332
33333333 def check_assignment (
3334- self ,
3335- lvalue : Lvalue ,
3336- rvalue : Expression ,
3337- infer_lvalue_type : bool = True ,
3338- new_syntax : bool = False ,
3334+ self , lvalue : Lvalue , rvalue : Expression , infer_lvalue_type : bool = True
33393335 ) -> None :
33403336 """Type check a single assignment: lvalue = rvalue."""
33413337 if isinstance (lvalue , (TupleExpr , ListExpr )):
@@ -3413,15 +3409,6 @@ def check_assignment(
34133409 # We are replacing partial<None> now, so the variable type
34143410 # should remain optional.
34153411 self .set_inferred_type (var , lvalue , make_optional_type (fallback ))
3416- elif (
3417- is_literal_none (rvalue )
3418- and isinstance (lvalue , NameExpr )
3419- and isinstance (lvalue .node , Var )
3420- and lvalue .node .is_initialized_in_class
3421- and not new_syntax
3422- ):
3423- # Allow None's to be assigned to class variables with non-Optional types.
3424- rvalue_type = lvalue_type
34253412 elif (
34263413 isinstance (lvalue , MemberExpr ) and lvalue .kind is None
34273414 ): # Ignore member access to modules
@@ -5303,9 +5290,7 @@ def visit_operator_assignment_stmt(self, s: OperatorAssignmentStmt) -> None:
53035290 # There is no __ifoo__, treat as x = x <foo> y
53045291 expr = OpExpr (s .op , s .lvalue , s .rvalue )
53055292 expr .set_line (s )
5306- self .check_assignment (
5307- lvalue = s .lvalue , rvalue = expr , infer_lvalue_type = True , new_syntax = False
5308- )
5293+ self .check_assignment (lvalue = s .lvalue , rvalue = expr , infer_lvalue_type = True )
53095294 self .check_final (s )
53105295
53115296 def visit_assert_stmt (self , s : AssertStmt ) -> None :
0 commit comments