diff --git a/doc/whatsnew/fragments/5288.false_positive b/doc/whatsnew/fragments/5288.false_positive new file mode 100644 index 0000000000..bdc6966225 --- /dev/null +++ b/doc/whatsnew/fragments/5288.false_positive @@ -0,0 +1,4 @@ +Fix various false positives for functions that return directly from +structural pattern matching cases. + +Closes #5288 diff --git a/tests/functional/u/unpacking/unpacking_non_sequence_py310.py b/tests/functional/u/unpacking/unpacking_non_sequence_py310.py new file mode 100644 index 0000000000..73492706a0 --- /dev/null +++ b/tests/functional/u/unpacking/unpacking_non_sequence_py310.py @@ -0,0 +1,11 @@ +"""Test returns from structural pattern matching cases.""" + +def unpack(num) -> tuple[int, int]: + """Return a tuple of integers.""" + match num: + case 1: + return 1, 1 + case _: + return 0, 0 + +x, y = unpack(1) diff --git a/tests/functional/u/unpacking/unpacking_non_sequence_py310.rc b/tests/functional/u/unpacking/unpacking_non_sequence_py310.rc new file mode 100644 index 0000000000..68a8c8ef15 --- /dev/null +++ b/tests/functional/u/unpacking/unpacking_non_sequence_py310.rc @@ -0,0 +1,2 @@ +[testoptions] +min_pyver=3.10