@@ -344,7 +344,9 @@ def visit_sequence_pattern(self, o: SequencePattern) -> PatternType:
344
344
contracted_rest_inner_types .append (rest )
345
345
self .update_type_map (captures , type_map )
346
346
if s :
347
- self .update_type_map (captures , {subject : typ for subject in s })
347
+ self .update_type_map (
348
+ captures , {subject : typ for subject in s }, fail_multiple_assignments = False
349
+ )
348
350
349
351
new_inner_types = self .expand_starred_pattern_types (
350
352
contracted_new_inner_types , star_position , len (inner_types ), unpack_index is not None
@@ -803,7 +805,10 @@ def generate_types_from_names(self, type_names: list[str]) -> list[Type]:
803
805
return types
804
806
805
807
def update_type_map (
806
- self , original_type_map : dict [Expression , Type ], extra_type_map : dict [Expression , Type ]
808
+ self ,
809
+ original_type_map : dict [Expression , Type ],
810
+ extra_type_map : dict [Expression , Type ],
811
+ fail_multiple_assignments : bool = True ,
807
812
) -> None :
808
813
# Calculating this would not be needed if TypeMap directly used literal hashes instead of
809
814
# expressions, as suggested in the TODO above it's definition
@@ -812,9 +817,10 @@ def update_type_map(
812
817
if literal_hash (expr ) in already_captured :
813
818
if (node := get_var (expr )) is None :
814
819
continue
815
- self .msg .fail (
816
- message_registry .MULTIPLE_ASSIGNMENTS_IN_PATTERN .format (node .name ), expr
817
- )
820
+ if fail_multiple_assignments :
821
+ self .msg .fail (
822
+ message_registry .MULTIPLE_ASSIGNMENTS_IN_PATTERN .format (node .name ), expr
823
+ )
818
824
else :
819
825
original_type_map [expr ] = typ
820
826
0 commit comments