diff options
-rw-r--r-- | doc/whatsnew/fragments/5288.false_positive | 4 | ||||
-rw-r--r-- | tests/functional/u/unpacking/unpacking_non_sequence_py310.py | 11 | ||||
-rw-r--r-- | tests/functional/u/unpacking/unpacking_non_sequence_py310.rc | 2 |
3 files changed, 17 insertions, 0 deletions
diff --git a/doc/whatsnew/fragments/5288.false_positive b/doc/whatsnew/fragments/5288.false_positive new file mode 100644 index 000000000..bdc696622 --- /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 000000000..73492706a --- /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 000000000..68a8c8ef1 --- /dev/null +++ b/tests/functional/u/unpacking/unpacking_non_sequence_py310.rc @@ -0,0 +1,2 @@ +[testoptions] +min_pyver=3.10 |