Repository: PyCQA/pyflakes (language: python)

Issue:
F811 incorrectly raised for type annotation of imported variable
The following piece of code raises F811 error in pyflakes 2.3.0:
```python
        from django.core.files.storage import default_storage
        default_storage: Storage
        file_path = os.path.join(constants.FILE_FIELD_UPLOAD_DIR_NAME, value.name)
        value = default_storage.save(file_path, value)
```

I am using pyflakes with flake8 and getting this output:
```
F811 redefinition of unused 'default_storage' from line 124
        default_storage: Storage
        ^
1     F811 redefinition of unused 'default_storage' from line 124
```

the code works correctly and `default_storage: Storage` does not redefine the variable, and `default_storage` is used two lines below.


Discussion / hints:
can confirm -- looks like a slight regression in #535 (which introduces annotated-assignments without values as types-only bindings) -- probably need to special case this particular situation of an annotation-only assignment of an imported name

Fix patch:
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index 01bcf508..48d38416 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -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


Test patch:
diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py
index 9e7ca140..f131034a 100644
--- a/pyflakes/test/test_type_annotations.py
+++ b/pyflakes/test/test_type_annotations.py
@@ -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