Skip to content

Commit 3de8e61

Browse files
authored
Annotations no longer redefine names (#619)
1 parent 22eaa06 commit 3de8e61

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pyflakes/checker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,10 @@ class Annotation(Binding):
548548
annotation.
549549
"""
550550

551+
def redefines(self, other):
552+
"""An Annotation doesn't define any name, so it cannot redefine one."""
553+
return False
554+
551555

552556
class FunctionDefinition(Definition):
553557
pass

pyflakes/test/test_type_annotations.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ def g(t: 'T'): pass
283283
a: 'a: "A"'
284284
''', m.ForwardAnnotationSyntaxError)
285285

286+
@skipIf(version_info < (3, 6), 'new in Python 3.6')
287+
def test_annotating_an_import(self):
288+
self.flakes('''
289+
from a import b, c
290+
b: c
291+
print(b)
292+
''')
293+
286294
@skipIf(version_info < (3, 6), 'new in Python 3.6')
287295
def test_unused_annotation(self):
288296
# Unused annotations are fine in module and class scope

0 commit comments

Comments
 (0)