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

self-assigning-variable false positive on tuple unpacking #3433

Closed
conqp opened this issue Mar 2, 2020 · 0 comments
Closed

self-assigning-variable false positive on tuple unpacking #3433

conqp opened this issue Mar 2, 2020 · 0 comments

Comments

@conqp
Copy link

conqp commented Mar 2, 2020

Steps to reproduce

Use one-element-tuple unpacking like var, = var

Current behavior

Get warning W0127: Assigning the same variable 'var' to itself (self-assigning-variable)

Expected behavior

Get no warning at all.

pylint --version output

pylint 2.4.4
astroid 2.3.3
Python 3.8.1 (default, Jan 22 2020, 06:38:00) 
[GCC 9.2.0]

Actual use case

Variable previous in the following example:

def check_state_change(system, check):
    """Checks the state change for the respective system and check."""

    select = check.select().where(check.system == system)
    select = select.order_by(check.timestamp.desc()).limit(2)

    try:
        last, *previous = select
    except ValueError:
        raise NotChecked(system, check)

    if previous:
        previous, = previous

        if last.successful and not previous.successful:
            return CheckState(system, last, State.RECOVERED)

        if previous.successful and not last.successful:
            return CheckState(system, last, State.FAILED)

        return CheckState(system, last, State.UNCHANGED)

    if last.successful:
        return CheckState(system, last, State.RECOVERED)

    return CheckState(system, last, State.FAILED)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant