Merge pull request #19136 from github/tausbn/python-modernise-mixed-tuple-returns-query

Python: Modernize `py/mixed-tuple-returns`
This commit is contained in:
Taus
2025-04-01 17:31:56 +02:00
committed by GitHub
4 changed files with 22 additions and 7 deletions

View File

@@ -1,2 +1 @@
| functions_test.py:306:1:306:39 | Function returning_different_tuple_sizes | returning_different_tuple_sizes returns $@ and $@. | functions_test.py:308:16:308:18 | Tuple | tuple of size 2 | functions_test.py:310:16:310:20 | Tuple | tuple of size 3 |
| functions_test.py:324:1:324:50 | Function indirectly_returning_different_tuple_sizes | indirectly_returning_different_tuple_sizes returns $@ and $@. | functions_test.py:319:12:319:14 | Tuple | tuple of size 2 | functions_test.py:322:12:322:16 | Tuple | tuple of size 3 |

View File

@@ -321,7 +321,7 @@ def function_returning_2_tuple():
def function_returning_3_tuple():
return 1,2,3
def indirectly_returning_different_tuple_sizes(x):
def indirectly_returning_different_tuple_sizes(x): # OK, since we only look at local tuple returns
if x:
return function_returning_2_tuple()
else:
@@ -347,3 +347,9 @@ def ok_match2(x): # FP
return 0
case _:
return 1
def ok_tuple_returns_captured_in_type(x: bool) -> tuple[int, ...]: # OK because there is a type annotation present
if x:
return 1, 2
else:
return 1, 2, 3