Skip to content

Commit be88036

Browse files
authored
Fix annotation of posonlyarg (#508)
1 parent 1911c20 commit be88036

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pyflakes/checker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,10 @@ def addArgs(arglist):
17991799
addArgs(node.args.args)
18001800
defaults = node.args.defaults
18011801
else:
1802+
if PY38_PLUS:
1803+
for arg in node.args.posonlyargs:
1804+
args.append(arg.arg)
1805+
annotations.append(arg.annotation)
18021806
for arg in node.args.args + node.args.kwonlyargs:
18031807
args.append(arg.arg)
18041808
annotations.append(arg.annotation)

pyflakes/test/test_type_annotations.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,11 @@ def t(self) -> Y:
418418
Y = 2
419419
return Y
420420
""", m.UndefinedName)
421+
422+
@skipIf(version_info < (3, 8), 'new in Python 3.8')
423+
def test_positional_only_argument_annotations(self):
424+
self.flakes("""
425+
from x import C
426+
427+
def f(c: C, /): ...
428+
""")

0 commit comments

Comments
 (0)