@@ -1495,7 +1495,7 @@ def check_func_def(
14951495 new_frame .types [key ] = narrowed_type
14961496 self .binder .declarations [key ] = old_binder .declarations [key ]
14971497
1498- if self .options .allow_redefinition_new and not self .is_stub :
1498+ if self .options .allow_redefinition and not self .is_stub :
14991499 # Add formal argument types to the binder.
15001500 for arg in defn .arguments :
15011501 # TODO: Add these directly using a fast path (possibly "put")
@@ -3439,7 +3439,7 @@ def check_assignment(
34393439 # unpleasant, and a generalization of this would
34403440 # be an improvement!
34413441 if (
3442- not self .options .allow_redefinition_new
3442+ not self .options .allow_redefinition
34433443 and is_literal_none (rvalue )
34443444 and isinstance (lvalue , NameExpr )
34453445 and lvalue .kind == LDEF
@@ -3499,7 +3499,7 @@ def check_assignment(
34993499 ):
35003500 lvalue .node .type = remove_instance_last_known_values (lvalue_type )
35013501 elif (
3502- self .options .allow_redefinition_new
3502+ self .options .allow_redefinition
35033503 and lvalue_type is not None
35043504 and not isinstance (lvalue_type , PartialType )
35053505 # Note that `inferred is not None` is not a reliable check here, because
@@ -4482,7 +4482,7 @@ def check_lvalue(
44824482 # When revisiting the initial assignment (for example in a loop),
44834483 # treat is as regular if redefinitions are allowed.
44844484 skip_definition = (
4485- self .options .allow_redefinition_new
4485+ self .options .allow_redefinition
44864486 and isinstance (lvalue , NameExpr )
44874487 and isinstance (lvalue .node , Var )
44884488 and lvalue .node .is_inferred
@@ -4513,7 +4513,7 @@ def check_lvalue(
45134513 elif isinstance (lvalue , NameExpr ):
45144514 lvalue_type = self .expr_checker .analyze_ref_expr (lvalue , lvalue = True )
45154515 if (
4516- self .options .allow_redefinition_new
4516+ self .options .allow_redefinition
45174517 and isinstance (lvalue .node , Var )
45184518 # We allow redefinition for function arguments inside function body.
45194519 # Although we normally do this for variables without annotation, users
@@ -4601,15 +4601,15 @@ def infer_variable_type(
46014601 init_type = strip_type (init_type )
46024602
46034603 self .set_inferred_type (name , lvalue , init_type )
4604- if self .options .allow_redefinition_new :
4604+ if self .options .allow_redefinition :
46054605 self .binder .assign_type (lvalue , init_type , init_type )
46064606
46074607 def infer_partial_type (self , name : Var , lvalue : Lvalue , init_type : Type ) -> bool :
46084608 init_type = get_proper_type (init_type )
46094609 if isinstance (init_type , NoneType ) and (
4610- isinstance (lvalue , MemberExpr ) or not self .options .allow_redefinition_new
4610+ isinstance (lvalue , MemberExpr ) or not self .options .allow_redefinition
46114611 ):
4612- # When using --allow-redefinition-new , None types aren't special
4612+ # When using --allow-redefinition, None types aren't special
46134613 # when inferring simple variable types.
46144614 partial_type = PartialType (None , name )
46154615 elif isinstance (init_type , Instance ):
@@ -4857,7 +4857,7 @@ def check_simple_assignment(
48574857 get_proper_type (lvalue_type ), AnyType
48584858 )
48594859
4860- # If redefinitions are allowed (i.e. we have --allow-redefinition-new
4860+ # If redefinitions are allowed (i.e. we have --allow-redefinition
48614861 # and a variable without annotation) or if a variable has union type we
48624862 # try inferring r.h.s. twice with a fallback type context. The only exception
48634863 # is TypedDicts, they are often useless without context.
@@ -5047,8 +5047,8 @@ def replace_partial_type(
50475047 # Updating a partial type should invalidate expression caches.
50485048 self .binder .version += 1
50495049 del partial_types [var ]
5050- if self .options .allow_redefinition_new :
5051- # When using --allow-redefinition-new , binder tracks all types of
5050+ if self .options .allow_redefinition :
5051+ # When using --allow-redefinition, binder tracks all types of
50525052 # simple variables.
50535053 n = NameExpr (var .name )
50545054 n .node = var
@@ -5463,10 +5463,10 @@ def visit_try_without_finally(self, s: TryStmt, try_frame: bool) -> None:
54635463 if isinstance (var .node , Var ):
54645464 new_type = DeletedType (source = source )
54655465 var .node .type = new_type
5466- if self .options .allow_redefinition_new :
5466+ if self .options .allow_redefinition :
54675467 # TODO: Should we use put() here?
54685468 self .binder .assign_type (var , new_type , new_type )
5469- if not self .options .allow_redefinition_new :
5469+ if not self .options .allow_redefinition :
54705470 self .binder .cleanse (var )
54715471 if s .else_body :
54725472 self .accept (s .else_body )
@@ -8373,7 +8373,7 @@ def visit_nonlocal_decl(self, o: NonlocalDecl, /) -> None:
83738373 return None
83748374
83758375 def visit_global_decl (self , o : GlobalDecl , / ) -> None :
8376- if self .options .allow_redefinition_new :
8376+ if self .options .allow_redefinition :
83778377 # Add names to binder, since their types could be widened
83788378 for name in o .names :
83798379 sym = self .globals .get (name )
@@ -9199,7 +9199,7 @@ def is_valid_inferred_type(
91999199 # type could either be NoneType or an Optional type, depending on
92009200 # the context. This resolution happens in leave_partial_types when
92019201 # we pop a partial types scope.
9202- return is_lvalue_final or (not is_lvalue_member and options .allow_redefinition_new )
9202+ return is_lvalue_final or (not is_lvalue_member and options .allow_redefinition )
92039203 elif isinstance (proper_type , UninhabitedType ):
92049204 return False
92059205 return not typ .accept (InvalidInferredTypes ())
0 commit comments