diff --git a/mypy/checkpattern.py b/mypy/checkpattern.py index 0e4786910e11..f0854145fea5 100644 --- a/mypy/checkpattern.py +++ b/mypy/checkpattern.py @@ -264,7 +264,8 @@ def visit_sequence_pattern(self, o: SequencePattern) -> PatternType: star_expr = None for t in current_type.items: - match_type, rest_type, captures = self.accept(o, t) + with self.msg.filter_errors(): + match_type, rest_type, captures = self.accept(o, t) match_types.append(match_type) rest_types.append(rest_type) if not is_uninhabited(match_type): diff --git a/test-data/unit/check-python310.test b/test-data/unit/check-python310.test index 33b952f48f49..362b28f03654 100644 --- a/test-data/unit/check-python310.test +++ b/test-data/unit/check-python310.test @@ -4019,3 +4019,15 @@ def enum_then_dummy_class(arg: DummyClass | Literal[MyEnum.RELEVANT]): case _: pass # E: Statement is unreachable [builtins fixtures/tuple.pyi] + +[case testMatchSequencePatternUnionTupleNoUnreachable] +# flags: --warn-unreachable +def f(value: tuple[None, int] | tuple[int, None] | tuple[int, int]) -> None: + match value: + case (None, int(y)): + pass + case (int(x), None): + pass + case (int(x), int(y)): + pass +[builtins fixtures/tuple.pyi]