pylint icon indicating copy to clipboard operation
pylint copied to clipboard

False positive: unused-variable + undefined-variable when using := operator in stacked decorators

Open abaumfalk opened this issue 1 year ago • 0 comments

Bug description

"""The following code should lint ok, but pylint issues undefined- / unused-variable l"""
import pytest


@pytest.mark.parametrize("x", l := [1, 2, 3])
@pytest.mark.parametrize("y", l)
def test_demo(x, y):
    """pylint demo"""
    _ = [x, y]

Configuration

No response

Command used

pylint test_pylint.py

Pylint output

************* Module test.configdb.config_utils.test_pylint
test_pylint.py:6:30: E0602: Undefined variable 'l' (undefined-variable)
test_pylint.py:5:30: W0612: Unused variable 'l' (unused-variable)

Expected behavior

linting should be ok

Pylint version

$ pylint --version
pylint 3.2.0
astroid 3.2.1
Python 3.10.13 (main, Jan 12 2024, 16:58:07) [GCC 11.4.0]

OS / Environment

Ubuntu 22.04.4 LTS

Additional dependencies

pytest==7.1.1

abaumfalk avatar May 17 '24 09:05 abaumfalk