Skip to content

Avoid re-using symbol in RUF024 fix#24316

Merged
charliermarsh merged 1 commit intomainfrom
charlie/sim
Mar 30, 2026
Merged

Avoid re-using symbol in RUF024 fix#24316
charliermarsh merged 1 commit intomainfrom
charlie/sim

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

Summary

Follows the suggestion from #24304 whereby if key is used, we try key_0, key_1, etc.

Closes #24304.

@charliermarsh charliermarsh added bug Something isn't working fixes Related to suggested fixes for violations labels Mar 30, 2026
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Mar 30, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@charliermarsh charliermarsh marked this pull request as ready for review March 30, 2026 20:28
@astral-sh-bot astral-sh-bot bot requested a review from amyreese March 30, 2026 20:28
@charliermarsh charliermarsh merged commit fc94581 into main Mar 30, 2026
42 checks passed
@charliermarsh charliermarsh deleted the charlie/sim branch March 30, 2026 20:30
carljm added a commit that referenced this pull request Mar 31, 2026
* main: (35 commits)
  Store definition indexes as u32 (#24307)
  Avoid re-using symbol in RUF024 fix (#24316)
  [ty] Add materialization to `Divergent` type (#24255)
  [ty] Make `Divergent` a top-level type variant (#24252)
  [ty] Fix nested global and nonlocal lookups through forwarding scopes (#24279)
  Fetch the cargo-dist binary directly instead of using the installer (#24258)
  [ty] Fix panic on `list[Annotated[()]]` (#24303)
  Don't measure the AST deallocation time in parser benchmarks (#24301)
  Enable CodSpeed's memory benchmarks for simulation benchmarks (#24298)
  Upgrade imara-diff to 0.2.0 (#24299)
  [ty] Represent `InitVar` as a special form internally, not a class (#24248)
  `RUF067`: Allow dunder-named assignments in non-strict mode
  [`pyupgrade`] UP018 should detect more unnecessarily wrapped literals (UP018) (#24093)
  [ty] Remove unused `system.glob` method (#24300)
  [ty] Reject functional TypedDict with mismatched name (#24295)
  Update Rust crate arc-swap to v1.9.0 (#24292)
  [ty] Remove unused `@Todo(Functional TypedDicts)` (#24297)
  Update CodSpeedHQ/action action to v4.12.1 (#24290)
  Update taiki-e/install-action action to v2.69.6 (#24293)
  Update Rust crate toml to v1.0.7 (#24289)
  ...
let mut index = 0;
loop {
let candidate = format!("{base}_{index}");
if semantic.is_available(&candidate) {
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.

We just have to hope that we never apply two fixes in the same scope in a single fix iteration 😆

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I did think about this lol. I’m not sure that we have a great mechanism for avoiding it today without imposing some harsh restrictions on fixes.

dylwil3 added a commit that referenced this pull request Apr 2, 2026
…24363)

Closes #24335

As suggested, we use the new `fresh_binding` helper from #24316

Note that the issue with this fix was already brought up in the
discussion in #9052 (see also #9059), where it was decided that it was
okay because the fix was already marked as unsafe.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fixes Related to suggested fixes for violations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RUF024 fix shadows a variable named key

3 participants