-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
pylint-dev/astroid
#2901Labels
Assignment expressionRelated to the walrus operator / assignment expressionRelated to the walrus operator / assignment expressionC: undefined-variableIssues related to 'undefined-variable' checkIssues related to 'undefined-variable' checkC: unused-variableDecoratorsFalse Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the code
Description
Bug description
The closest open issue I could find was #7538, but this has different error codes
Curiously, if I put the offending line outside of the decorator, there is no error
def decorate(x):
def wrapped(f):
print(x)
return f()
return wrapped
original = {"key": "value", "this": "that"}
@decorate((d := original.copy()) and d.pop("key") and d) # pylint error
def g(): print("g")% python test.py
{'this': 'that'}
gConfiguration
No response
Command used
pylint test.py --disable=CPylint output
************* Module test
t.py:9:37: E0602: Undefined variable 'd' (undefined-variable)
t.py:9:54: E0602: Undefined variable 'd' (undefined-variable)
t.py:9:11: W0612: Unused variable 'd' (unused-variable)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)Expected behavior
no error
Pylint version
pylint 2.17.0
astroid 2.15.0
Python 3.10.5 (main, Jul 29 2022, 12:30:46) [Clang 13.0.0 (clang-1300.0.27.3)]OS / Environment
% uname
DarwinAdditional dependencies
No response
kalekundert
Metadata
Metadata
Assignees
Labels
Assignment expressionRelated to the walrus operator / assignment expressionRelated to the walrus operator / assignment expressionC: undefined-variableIssues related to 'undefined-variable' checkIssues related to 'undefined-variable' checkC: unused-variableDecoratorsFalse Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the code