Repository: PyCQA/pyflakes

Issue:
2.1.0 is broken
https://travis-ci.org/borgbackup/borg/jobs/486513787

Comments:

Patch:
diff --git a/.appveyor.yml b/.appveyor.yml
index f7d7aa2..0e05ec3 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -1,8 +1,6 @@
 # To activate, change the Appveyor settings to use `.appveyor.yml`.
 install:
-  - ps: "[Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
-
-  - python -m pip install --upgrade virtualenv pip setuptools tox
+  - python -m pip install --upgrade tox virtualenv
 
   # Fetch the three main PyPy releases
   - ps: (New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy-2.6.1-win32.zip', "$env:appveyor_build_folder\pypy-2.6.1-win32.zip")
@@ -13,36 +11,16 @@ install:
   - ps: 7z x pypy2-v5.3.1-win32.zip | Out-Null
   - move pypy2-v5.3.1-win32 C:\
 
-  # Note: pypy3-v5.10.0 is commented out as it needs an updated pip to
-  # recognise the new python_requires, but there's a pypy bug preventing that.
-  # It's been fixed and will be in the next 5.10.1 release.
-  # See https://bitbucket.org/pypy/pypy/issues/2720/ensurepip-on-pypy-c-jit-93579-a4194a67868f
-  # and https://stackoverflow.com/q/47999518/724176.
-
-#  - ps: (New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy3-v5.10.0-win32.zip', "$env:appveyor_build_folder\pypy3-v5.10.0-win32.zip")
-#  - ps: 7z x pypy3-v5.10.0-win32.zip | Out-Null
-#  - move pypy3-v5.10.0-win32 C:\
-
-  # workaround https://github.com/pypa/virtualenv/issues/93
-  - mkdir C:\python33\tcl\tcl8.6
-  - mkdir C:\python33\tcl\tk8.6
-#  - mkdir C:\pypy3-v5.10.0-win32\tcl\tcl8.6
-#  - mkdir C:\pypy3-v5.10.0-win32\tcl\tk8.6
-
-  # Only pypy2-5.3.1 is integrated into tox, as pypy3-2.4.0 fails and
-  # a Windows distribution of pypy3-5.2 isnt available yet.
-  - ps: $env:path = "$env:path;C:\pypy2-v5.3.1-win32;C:\pypy-2.6.1-win32\bin"
-
-  # pypy3-2.4.0 and pypy-2.6.1 are manually bootstrapped and tested
-  - ps: (New-Object Net.WebClient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', "$env:appveyor_build_folder\get-pip.py")
-  # errors are ignored due to https://github.com/pypa/pip/issues/2669#issuecomment-136405390
-#  - ps: C:\pypy3-v5.10.0-win32\pypy3 "$env:appveyor_build_folder\get-pip.py"; echo "ignore error"
-#  - ps: C:\pypy3-v5.10.0-win32\pypy3 -m pip install -U --force-reinstall pip setuptools; echo "ignore error"
-  - ps: C:\pypy-2.6.1-win32\pypy "$env:appveyor_build_folder\get-pip.py"
+  # TODO: pypy 6.0.0 offsets are different
+  #- ps: (New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy3-v6.0.0-win32.zip', "$env:appveyor_build_folder\pypy3-v6.0.0-win32.zip")
+  #- ps: 7z x pypy3-v6.0.0-win32.zip | Out-Null
+  #- move pypy3-v6.0.0-win32 C:\
 
 build: off
 
 test_script:
   - python -m tox
-#  - C:\pypy3-v5.10.0-win32\pypy3 -m unittest discover pyflakes
   - C:\pypy-2.6.1-win32\pypy -m unittest discover pyflakes
+  - C:\pypy2-v5.3.1-win32\pypy -m unittest discover pyflakes
+  # TODO: pypy 6.0.0 offsets are different
+  #- C:\pypy3-v6.0.0-win32\pypy3 -m unittest discover pyflakes
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index 650d788..70aaff2 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -529,6 +529,7 @@ def is_typing_overload(value, scope):
             (
                 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


Test patch:
diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py
index 40397e8..5af4441 100644
--- a/pyflakes/test/test_type_annotations.py
+++ b/pyflakes/test/test_type_annotations.py
@@ -39,6 +39,28 @@ class TestTypeAnnotations(TestCase):
             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('''