Do not treat a walrus argument as a keyword argument (#242)
Build / lint (push) Waiting to run
Build / test (false, 3.10) (push) Waiting to run
Build / test (false, 3.11) (push) Waiting to run
Build / test (false, 3.12) (push) Waiting to run
Build / test (false, 3.13) (push) Waiting to run
Build / test (false, 3.8) (push) Waiting to run
Build / test (false, 3.9) (push) Waiting to run
Build / coverage (push) Waiting to run

Closes #212
This commit is contained in:
Sanjay Santhanam
2026-07-31 20:33:49 +00:00
committed by GitHub
parent 512e78c1a8
commit 7f5b142b54
2 changed files with 5 additions and 0 deletions
+3
View File
@@ -936,6 +936,9 @@ class _ArglistRule(SyntaxRule):
self.add_issue(argument, message=message)
else:
kw_unpacking_only = True
elif argument.children[1] == ':=':
# f(a := 1) is a positional argument, not a keyword one.
pass
else: # Is a keyword argument.
kw_only = True
if first.type == 'name':
+2
View File
@@ -366,6 +366,8 @@ def test_valid_fstrings(code):
'a[(b:=0)]',
'a[(b:=0, c:=0)]',
'a[(b:=0):1:2]',
'f(a := 1, b)',
'f(a := 1, b, c := 2)',
]
)
def test_valid_namedexpr(code):