-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Needs triage 📥Just created, needs acknowledgment, triage, and proper labellingJust created, needs acknowledgment, triage, and proper labelling
Description
Bug description
"""Example to show incorrect diagnostics for the walrus operator"""
def f(a, b):
"""A simple function. When called, we will use the walrus operator."""
print("f", a, b)
f(l := [1, 2, 3], [x * 2 for x in l]) # THIS PASSES
class Decor: # pylint: disable=too-few-public-methods
"""A simple decorator with arguments. When called, we will use the walrus operator."""
def __init__(self, a, b):
self.a = a
self.b = b
def __call__(self, fn):
print("decor", self.a, self.b)
return fn
@Decor(k := [-1, -2, -3], [x * 2 for x in k]) # THIS FAILS
def g():
"""A simple function with the only purpose to be decorated."""
print("g")
g()Configuration
Command used
pylint walrus.pyPylint output
************* Module walrus
walrus.py:20:42: E0602: Undefined variable 'k' (undefined-variable)
walrus.py:20:7: W0612: Unused variable 'k' (unused-variable)Expected behavior
Not to report the error or the warning.
Pylint version
pylint 4.0.4
astroid 4.0.2
Python 3.13.7 (main, Aug 14 2025, 11:12:11) [Clang 17.0.0 (clang-1700.0.13.3)]OS / Environment
macOS 15.6.1, Darwin 24.6.0 arm64
Additional dependencies
Metadata
Metadata
Assignees
Labels
Needs triage 📥Just created, needs acknowledgment, triage, and proper labellingJust created, needs acknowledgment, triage, and proper labelling