Repository: PyCQA/pyflakes (python)

Issue:
F401 (imported but unused) false positive on Foo when using def x(a: Foo, /, *, b: Bar)
```python
from datetime import datetime as Foo, time as Bar


def x(a: Foo, /, *, b: Bar):
    pass
```

Running this on the file results in:

```
› flake8 --version  
3.7.9 (mccabe: 0.6.1, pycodestyle: 2.5.0, pyflakes: 2.1.1) CPython 3.8.1 on Linux
› pyflakes --version
2.1.1 Python 3.8.1 on Linux
› flake8 example.py 
example.py:1:1: F401 'datetime.datetime as Foo' imported but unused
› pyflakes example.py
example.py:1: 'datetime.datetime as Foo' imported but unused
```

Pull request description:
Fix annotation of posonlyarg
Resolves #507

Patch:
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index c8ccf56..d157008 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -1799,6 +1799,10 @@ class Checker(object):
             addArgs(node.args.args)
             defaults = node.args.defaults
         else:
+            if PY38_PLUS:
+                for arg in node.args.posonlyargs:
+                    args.append(arg.arg)
+                    annotations.append(arg.annotation)
             for arg in node.args.args + node.args.kwonlyargs:
                 args.append(arg.arg)
                 annotations.append(arg.annotation)


Test patch:
diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py
index 289535d..1fa4f5e 100644
--- a/pyflakes/test/test_type_annotations.py
+++ b/pyflakes/test/test_type_annotations.py
@@ -418,3 +418,11 @@ class TestTypeAnnotations(TestCase):
                 Y = 2
                 return Y
         """, m.UndefinedName)
+
+    @skipIf(version_info < (3, 8), 'new in Python 3.8')
+    def test_positional_only_argument_annotations(self):
+        self.flakes("""
+        from x import C
+
+        def f(c: C, /): ...
+        """)