From 3de8e61202910033b1f8af96a1afcf8faabc37a0 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 24 Mar 2021 09:30:05 -0700 Subject: Annotations no longer redefine names (#619) --- pyflakes/checker.py | 4 ++++ pyflakes/test/test_type_annotations.py | 8 ++++++++ 2 files changed, 12 insertions(+) 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 @@ -283,6 +283,14 @@ class TestTypeAnnotations(TestCase): a: 'a: "A"' ''', 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 -- cgit v1.2.1