diff options
author | Anthony Sottile <asottile@umich.edu> | 2021-03-24 09:30:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-24 09:30:05 -0700 |
commit | 3de8e61202910033b1f8af96a1afcf8faabc37a0 (patch) | |
tree | e31dfde5750c79637077c05b39e3048a75234a48 | |
parent | 22eaa069d49d211fe6e8f06c00711064a8d5e733 (diff) | |
download | pyflakes-3de8e61202910033b1f8af96a1afcf8faabc37a0.tar.gz |
Annotations no longer redefine names (#619)
-rw-r--r-- | pyflakes/checker.py | 4 | ||||
-rw-r--r-- | pyflakes/test/test_type_annotations.py | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/pyflakes/checker.py b/pyflakes/checker.py index 01bcf50..48d3841 100644 --- a/pyflakes/checker.py +++ b/pyflakes/checker.py @@ -548,6 +548,10 @@ class Annotation(Binding): annotation. """ + def redefines(self, other): + """An Annotation doesn't define any name, so it cannot redefine one.""" + return False + class FunctionDefinition(Definition): pass diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py index 9e7ca14..f131034 100644 --- a/pyflakes/test/test_type_annotations.py +++ b/pyflakes/test/test_type_annotations.py @@ -284,6 +284,14 @@ class TestTypeAnnotations(TestCase): ''', m.ForwardAnnotationSyntaxError) @skipIf(version_info < (3, 6), 'new in Python 3.6') + def test_annotating_an_import(self): + self.flakes(''' + from a import b, c + b: c + print(b) + ''') + + @skipIf(version_info < (3, 6), 'new in Python 3.6') def test_unused_annotation(self): # Unused annotations are fine in module and class scope self.flakes(''' |