Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
abaumfalk opened this issue May 17, 2024 · 0 comments
Labels
C: undefined-variable Issues related to 'undefined-variable' check C: used-before-assignment Issues related to 'used-before-assignment' check Decorators False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation

Comments

@abaumfalk
Copy link

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 abaumfalk added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label May 17, 2024
@abaumfalk abaumfalk changed the title unused-variable + undefined-variable when using := operator in pytest.mark.parametrize False positive: unused-variable + undefined-variable when using := operator in pytest.mark.parametrize May 17, 2024
@jacobtylerwalls jacobtylerwalls added Decorators C: used-before-assignment Issues related to 'used-before-assignment' check C: undefined-variable Issues related to 'undefined-variable' check False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels May 17, 2024
@jacobtylerwalls jacobtylerwalls changed the title False positive: unused-variable + undefined-variable when using := operator in pytest.mark.parametrize False positive: unused-variable + undefined-variable when using := operator in stacked decorators May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: undefined-variable Issues related to 'undefined-variable' check C: used-before-assignment Issues related to 'used-before-assignment' check Decorators False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

No branches or pull requests

2 participants