diff options
author | Anthony Sottile <asottile@umich.edu> | 2020-01-17 12:24:47 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-17 12:24:47 -0800 |
commit | be88036019005b769596ca82fb7b82dfdffdca0f (patch) | |
tree | 8bd491a05e0613aff1da04a49274c36c03e063cd | |
parent | 1911c203a13826d2eb03d582d60874b91e36f4fc (diff) | |
download | pyflakes-be88036019005b769596ca82fb7b82dfdffdca0f.tar.gz |
Fix annotation of posonlyarg (#508)
-rw-r--r-- | pyflakes/checker.py | 4 | ||||
-rw-r--r-- | pyflakes/test/test_type_annotations.py | 8 |
2 files changed, 12 insertions, 0 deletions
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) 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, /): ... + """) |