Skip to content

[ruff] skip fix for RUF059 if dummy name is already bound (unused-unpacked-variable) - #18509

Merged
MichaReiser merged 2 commits into
astral-sh:mainfrom
chirizxc:fix/unused-unpacked-variable
Jun 11, 2025
Merged

MichaReiser merged 2 commits into
astral-sh:mainfrom
chirizxc:fix/unused-unpacked-variable

Conversation

@chirizxc

@chirizxc chirizxc commented Jun 6, 2025

Copy link
Copy Markdown
Contributor

Summary

/closes #18507

Test Plan

@github-actions

github-actions Bot commented Jun 6, 2025 •

Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre ntBre added bug An issue describing something that isn't working, or a PR that fixes a bug fixes Related to suggested fixes for violations labels Jun 6, 2025
Comment on lines +69 to +74
if scope
.bindings()
.any(|(_, id)| checker.semantic().binding(id).name(checker.source()) == renamed)
{
return None;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could use the following here (which is what we use in other places to test shadowing)

if ShadowedKind::new(binding, new_name, checker).shadows_any() {
return;
}

@MichaReiser

Copy link
Copy Markdown
Member

Thank you

@MichaReiser
MichaReiser merged commit dc322d2 into astral-sh:main Jun 11, 2025
@chirizxc
chirizxc deleted the fix/unused-unpacked-variable branch June 11, 2025 08:25
dcreager added a commit that referenced this pull request Jun 12, 2025
* main:
  [ty] Add some "inside string" tests for `object.<CURSOR>` completions
  [ty] Pull types on synthesized Python files created by mdtest (#18539)
  Update Rust crate anstyle to v1.0.11 (#18583)
  [`pyupgrade`] Fix `super(__class__, self)` detection in UP008 (super-call-with-parameters) (#18478)
  [ty] Generate the top and bottom materialization of a type (#18594)
  `SourceOrderVisitor` should visit the `Identifier` part of the `PatternKeyword` node (#18635)
  Update salsa (#18636)
  [ty] Update mypy_primer doc (#18638)
  [ty] Improve support for `object.<CURSOR>` completions
  [ty] Add `CoveringNode::find_last`
  [ty] Refactor covering node representation
  [ty] Infer the Python version from `--python=<system installation>` on Unix (#18550)
  [`flake8-return`] Fix `RET504` autofix generating a syntax error (#18428)
  Fix incorrect salsa `return_ref` attribute (#18605)
  Move corpus tests to `ty_python_semantic` (#18609)
  [`pyupgrade`] Don't offer fix for `Optional[None]` in non-pep604-annotation-optional (`UP045)` or non-pep604-annotation-union (`UP007`) (#18545)
  [`pep8-naming`] Suppress fix for `N804` and `N805` if the recommend name is already used (#18472)
  [`ruff`] skip fix for `RUF059` if dummy name is already bound (unused-unpacked-variable) (#18509)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue describing something that isn't working, or a PR that fixes a bug fixes Related to suggested fixes for violations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RUF059 fix renames variables without checking existing variable names

3 participants