Skip to content

Commit ec2f254

Browse files
committed
Refactor: replace make_simplified_union with UnionType.make_union in checkpattern.py (#8624)
This commit replaces all calls to make_simplified_union with UnionType.make_union in this file, as part of the codebase modernization effort in issue #8624.
1 parent 50afb03 commit ec2f254

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mypy/checkpattern.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def visit_or_pattern(self, o: OrPattern) -> PatternType:
196196

197197
captures[capture_list[0][0]] = typ
198198

199-
union_type = make_simplified_union(types)
199+
union_type = UnionType.make_union(types)
200200
return PatternType(union_type, current_type, captures)
201201

202202
def visit_value_pattern(self, o: ValuePattern) -> PatternType:
@@ -359,7 +359,7 @@ def get_sequence_type(self, t: Type, context: Context) -> Type | None:
359359
items = [self.get_sequence_type(item, context) for item in t.items]
360360
not_none_items = [item for item in items if item is not None]
361361
if not_none_items:
362-
return make_simplified_union(not_none_items)
362+
return UnionType.make_union(not_none_items)
363363
else:
364364
return None
365365

@@ -409,13 +409,13 @@ def contract_starred_pattern_types(
409409
new_middle.append(unpacked.args[0])
410410
else:
411411
new_middle.append(m)
412-
return list(prefix) + [make_simplified_union(new_middle)] + list(suffix)
412+
return list(prefix) + [UnionType.make_union(new_middle)] + list(suffix)
413413
else:
414414
if star_pos is None:
415415
return types
416416
new_types = types[:star_pos]
417417
star_length = len(types) - num_patterns
418-
new_types.append(make_simplified_union(types[star_pos : star_pos + star_length]))
418+
new_types.append(UnionType.make_union(types[star_pos : star_pos + star_length]))
419419
new_types += types[star_pos + star_length :]
420420
return new_types
421421

@@ -764,7 +764,7 @@ def construct_sequence_child(self, outer_type: Type, inner_type: Type) -> Type:
764764
for item in proper_type.items
765765
if self.can_match_sequence(get_proper_type(item))
766766
]
767-
return make_simplified_union(types)
767+
return UnionType.make_union(types)
768768
sequence = self.chk.named_generic_type("typing.Sequence", [inner_type])
769769
if is_subtype(outer_type, self.chk.named_type("typing.Sequence")):
770770
if isinstance(proper_type, TupleType):

0 commit comments

Comments
 (0)