Skip to content

Commit

Permalink
Fix typing.overload check to only check imported names (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile authored and sigmavirus24 committed Jan 31, 2019
1 parent 72bf8cc commit 2c29431
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyflakes/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ def is_typing_overload_decorator(node):
(
isinstance(node, ast.Name) and
node.id in scope and
isinstance(scope[node.id], ImportationFrom) and
scope[node.id].fullName == 'typing.overload'
) or (
isinstance(node, ast.Attribute) and
Expand Down
22 changes: 22 additions & 0 deletions pyflakes/test/test_type_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ def g(s):
return s
""")

def test_not_a_typing_overload(self):
"""regression test for @typing.overload detection bug in 2.1.0"""
self.flakes("""
x = lambda f: f
@x
def t():
pass
y = lambda f: f
@x
@y
def t():
pass
@x
@y
def t():
pass
""", m.RedefinedWhileUnused, m.RedefinedWhileUnused)

@skipIf(version_info < (3, 6), 'new in Python 3.6')
def test_variable_annotations(self):
self.flakes('''
Expand Down

0 comments on commit 2c29431

Please sign in to comment.