Skip to content

Commit 36be729

Browse files
authored
Merge pull request #2663 from tausbn/python-type-annotation-reuse-fp
Python: Add false positive test example for issue #2652.
2 parents f7f8dd4 + ead687d commit 36be729

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

python/ql/test/query-tests/Variables/unused/UnusedLocalVariable.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
| type_annotation_fp.py:5:5:5:7 | foo | The value assigned to local variable 'foo' is never used. |
12
| variables_test.py:29:5:29:5 | x | The value assigned to local variable 'x' is never used. |
23
| variables_test.py:89:5:89:5 | a | The value assigned to local variable 'a' is never used. |
34
| variables_test.py:89:7:89:7 | b | The value assigned to local variable 'b' is never used. |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# FP Type annotation counts as redefinition
2+
# See https://github.com/Semmle/ql/issues/2652
3+
4+
def type_annotation(x):
5+
foo = 5
6+
if x:
7+
foo : int
8+
do_stuff_with(foo)
9+
else:
10+
foo : float
11+
do_other_stuff_with(foo)

0 commit comments

Comments
 (0)