diff --git a/pyflakes/checker.py b/pyflakes/checker.py index 650d788c..70aaff20 100644 --- a/pyflakes/checker.py +++ b/pyflakes/checker.py @@ -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 diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py index 40397e87..5af4441f 100644 --- a/pyflakes/test/test_type_annotations.py +++ b/pyflakes/test/test_type_annotations.py @@ -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('''