Skip to content

Conversation

cclauss
Copy link

@cclauss cclauss commented Oct 4, 2025

Description

This is #1928 with fixes for ruff rule RUF059.

% pre-commit autoupdate

[https://github.com/pre-commit/pre-commit-hooks] updating v5.0.0 -> v6.0.0
[https://github.com/PyCQA/bandit] already up to date!
[https://github.com/astral-sh/ruff-pre-commit] updating v0.12.5 -> v0.13.3
[https://github.com/codespell-project/codespell] already up to date!
[https://github.com/asottile/pyupgrade] already up to date!

% ruff check --select=RUF059 --fix --unsafe-fixes

Found 7 errors (7 fixed, 0 remaining).

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

% pre-commit run --all-files

Also, note that the pre-commit.ci test below passes on this PR but does not on #1928.

Any specific deployment considerations

For example, documentation changes, usability, usage/costs, secrets, etc.

Docs

  • Docs updated? What were the changes:

% ruff rule RUF059

unused-unpacked-variable (RUF059)

Derived from the Ruff-specific rules linter.

Fix is sometimes available.

What it does

Checks for the presence of unused variables in unpacked assignments.

Why is this bad?

A variable that is defined but never used can confuse readers.

If a variable is intentionally defined-but-not-used, it should be
prefixed with an underscore, or some other value that adheres to the
[lint.dummy-variable-rgx] pattern.

Example

def get_pair():
    return 1, 2


def foo():
    x, y = get_pair()
    return x

Use instead:

def foo():
    x, _ = get_pair()
    return x

See also

This rule applies only to unpacked assignments. For regular assignments, see
unused-variable.

Options

  • lint.dummy-variable-rgx

@cclauss cclauss requested a review from SkalskiP as a code owner October 4, 2025 14:44
@CLAassistant
Copy link

CLAassistant commented Oct 4, 2025

CLA assistant check
All committers have signed the CLA.

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

Successfully merging this pull request may close these issues.

2 participants