From 7f5b142b54b2a04bcb4df358175d079e046c5bf7 Mon Sep 17 00:00:00 2001 From: Sanjay Santhanam <51058514+Sanjays2402@users.noreply.github.com> Date: Fri, 31 Jul 2026 13:33:49 -0700 Subject: [PATCH] Do not treat a walrus argument as a keyword argument (#242) Closes #212 --- parso/python/errors.py | 3 +++ test/test_python_errors.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/parso/python/errors.py b/parso/python/errors.py index c51a36d..b498af3 100644 --- a/parso/python/errors.py +++ b/parso/python/errors.py @@ -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': diff --git a/test/test_python_errors.py b/test/test_python_errors.py index a3fdaa1..56795f2 100644 --- a/test/test_python_errors.py +++ b/test/test_python_errors.py @@ -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):