Skip to content

Commit

Permalink
Annotations no longer redefine names (#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile committed Mar 24, 2021
1 parent 22eaa06 commit 3de8e61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pyflakes/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions pyflakes/test/test_type_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ def g(t: 'T'): pass
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
Expand Down

0 comments on commit 3de8e61

Please sign in to comment.