Skip to content

False positive used-before-assignment with multi-item with statement and tuple target #7545

Open
@ytoku

Description

@ytoku

Bug description

The used-before-assignment check reports false positive for the combination of multi-item with statement and tuple target.

import contextlib


@contextlib.contextmanager
def f():
    yield ("A", "B")


@contextlib.contextmanager
def g(_):
    yield "C"


with f() as (a, b), g(a) as c:
    pass

Configuration

No response

Command used

pylint --disable=missing-docstring --disable=invalid-name test.py

Pylint output

************* Module test
test.py:14:22: E0601: Using variable 'a' before assignment (used-before-assignment)

------------------------------------------------------------------
Your code has been rated at 2.86/10 (previous run: 2.86/10, +0.00)

Expected behavior

No error.

Pylint version

pylint 2.15.3
astroid 2.12.10
Python 3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0]

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: used-before-assignmentIssues related to 'used-before-assignment' checkFalse Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions