Merge pull request #2663 from tausbn/python-type-annotation-reuse-fp

Python: Add false positive test example for issue #2652.
This commit is contained in:
Taus
2021-02-16 18:46:15 +01:00
committed by GitHub
2 changed files with 12 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
| type_annotation_fp.py:5:5:5:7 | foo | The value assigned to local variable 'foo' is never used. |
| variables_test.py:29:5:29:5 | x | The value assigned to local variable 'x' is never used. |
| variables_test.py:89:5:89:5 | a | The value assigned to local variable 'a' is never used. |
| variables_test.py:89:7:89:7 | b | The value assigned to local variable 'b' is never used. |

View File

@@ -0,0 +1,11 @@
# FP Type annotation counts as redefinition
# See https://github.com/Semmle/ql/issues/2652
def type_annotation(x):
foo = 5
if x:
foo : int
do_stuff_with(foo)
else:
foo : float
do_other_stuff_with(foo)