@@ -4725,11 +4725,11 @@ def visit_if_stmt(self, s: IfStmt) -> None:
47254725
47264726 # XXX Issue a warning if condition is always False?
47274727 with self .binder .frame_context (can_skip = True , fall_through = 2 ):
4728- self .push_type_map (if_map , False )
4728+ self .push_type_map (if_map , from_assignment = False )
47294729 self .accept (b )
47304730
47314731 # XXX Issue a warning if condition is always True?
4732- self .push_type_map (else_map , False )
4732+ self .push_type_map (else_map , from_assignment = False )
47334733
47344734 with self .binder .frame_context (can_skip = False , fall_through = 2 ):
47354735 if s .else_body :
@@ -5310,20 +5310,21 @@ def visit_match_stmt(self, s: MatchStmt) -> None:
53105310 if b .is_unreachable or isinstance (
53115311 get_proper_type (pattern_type .type ), UninhabitedType
53125312 ):
5313- self .push_type_map (None , False )
5313+ self .push_type_map (None , from_assignment = False )
53145314 else_map : TypeMap = {}
53155315 else :
53165316 pattern_map , else_map = conditional_types_to_typemaps (
53175317 named_subject , pattern_type .type , pattern_type .rest_type
53185318 )
53195319 self .remove_capture_conflicts (pattern_type .captures , inferred_types )
5320- self .push_type_map (pattern_map , False )
5320+ self .push_type_map (pattern_map , from_assignment = False )
53215321 if pattern_map :
53225322 for expr , typ in pattern_map .items ():
53235323 self .push_type_map (
5324- self ._get_recursive_sub_patterns_map (expr , typ ), False
5324+ self ._get_recursive_sub_patterns_map (expr , typ ),
5325+ from_assignment = False ,
53255326 )
5326- self .push_type_map (pattern_type .captures , False )
5327+ self .push_type_map (pattern_type .captures , from_assignment = False )
53275328 if g is not None :
53285329 with self .binder .frame_context (can_skip = False , fall_through = 3 ):
53295330 gt = get_proper_type (self .expr_checker .accept (g ))
@@ -5349,11 +5350,11 @@ def visit_match_stmt(self, s: MatchStmt) -> None:
53495350 continue
53505351 type_map [named_subject ] = type_map [expr ]
53515352
5352- self .push_type_map (guard_map , False )
5353+ self .push_type_map (guard_map , from_assignment = False )
53535354 self .accept (b )
53545355 else :
53555356 self .accept (b )
5356- self .push_type_map (else_map , False )
5357+ self .push_type_map (else_map , from_assignment = False )
53575358
53585359 # This is needed due to a quirk in frame_context. Without it types will stay narrowed
53595360 # after the match.
@@ -7367,12 +7368,12 @@ def iterable_item_type(
73677368 def function_type (self , func : FuncBase ) -> FunctionLike :
73687369 return function_type (func , self .named_type ("builtins.function" ))
73697370
7370- def push_type_map (self , type_map : TypeMap , from_assignment : bool = True ) -> None :
7371+ def push_type_map (self , type_map : TypeMap , * , from_assignment : bool = True ) -> None :
73717372 if type_map is None :
73727373 self .binder .unreachable ()
73737374 else :
73747375 for expr , type in type_map .items ():
7375- self .binder .put (expr , type , from_assignment )
7376+ self .binder .put (expr , type , from_assignment = from_assignment )
73767377
73777378 def infer_issubclass_maps (self , node : CallExpr , expr : Expression ) -> tuple [TypeMap , TypeMap ]:
73787379 """Infer type restrictions for an expression in issubclass call."""
0 commit comments