Skip to content

Commit 1ca2590

Browse files
authored
Merge pull request #16764 from github/redsun82/python-match-fps
Python: tests with false positives around `match`
2 parents d7fbf68 + 147d66b commit 1ca2590

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
| functions_test.py:18:1:18:11 | Function cr1 | Mixing implicit and explicit returns may indicate an error as implicit returns always return None. |
22
| functions_test.py:22:1:22:11 | Function cr2 | Mixing implicit and explicit returns may indicate an error as implicit returns always return None. |
3+
| functions_test.py:336:1:336:16 | Function ok_match | Mixing implicit and explicit returns may indicate an error as implicit returns always return None. |

python/ql/test/query-tests/Functions/return_values/functions_test.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,12 @@ def indirectly_returning_different_tuple_sizes(x):
330330

331331
def mismatched_multi_assign(x):
332332
a,b = returning_different_tuple_sizes(x)
333-
return a,b
333+
return a,b
334+
335+
336+
def ok_match(x): # FP
337+
match x:
338+
case True | 'true':
339+
return 0
340+
case _:
341+
raise ValueError(x)

python/ql/test/query-tests/Statements/unreachable/UnreachableCode.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
| test.py:21:5:21:38 | For | This statement is unreachable. |
55
| test.py:28:9:28:21 | ExprStmt | This statement is unreachable. |
66
| test.py:84:5:84:21 | ExceptStmt | This statement is unreachable. |
7+
| test.py:144:13:144:16 | Pass | This statement is unreachable. |
8+
| test.py:147:9:148:16 | Case | This statement is unreachable. |

python/ql/test/query-tests/Statements/unreachable/test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,12 @@ def unreachable_catch_all_raise(x):
137137
pass
138138
else:
139139
raise ValueError(x)
140+
141+
def ok_match(x):
142+
match x:
143+
case False:
144+
pass # FP
145+
case True:
146+
pass
147+
case _: # FP
148+
pass

0 commit comments

Comments
 (0)