Skip to content

[refurb] Parenthesize generator arguments in FURB142 fixer (#21098)#24200

Merged
MichaReiser merged 1 commit intoastral-sh:mainfrom
bitloi:fix/issue-21098-furb142-generator-parens
Mar 26, 2026
Merged

[refurb] Parenthesize generator arguments in FURB142 fixer (#21098)#24200
MichaReiser merged 1 commit intoastral-sh:mainfrom
bitloi:fix/issue-21098-furb142-generator-parens

Conversation

@bitloi
Copy link
Copy Markdown
Contributor

@bitloi bitloi commented Mar 26, 2026

Summary

Parenthesize unparenthesized generator arguments in the FURB142 fixer when rewriting set.add(...) loops to set.update(...), so the rewrite preserves scoping and behavior. Added fixture/snapshot regressions for both unparenthesized and already-parenthesized generator arguments.

Test Plan

  • cargo test -p ruff_linter rule_forloopsetmutations_path_new_furb142_py_expects
  • cargo test -p ruff_linter refurb::tests::rules -- FURB142
  • cargo fmt --all --check
  • cargo clippy -p ruff_linter --all-targets --all-features -- -D warnings

Closes #21098

…sh#21098)

Preserve semantics when rewriting `set.add(...)` loops by parenthesizing unparenthesized generator arguments and add snapshot-backed regressions for both parenthesized and unparenthesized generator cases.
@astral-sh-bot astral-sh-bot bot requested a review from ntBre March 26, 2026 08:15
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Mar 26, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser added the fixes Related to suggested fixes for violations label Mar 26, 2026
Copy link
Copy Markdown
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Thank you

@MichaReiser MichaReiser merged commit fa07cda into astral-sh:main Mar 26, 2026
42 checks passed
@bitloi
Copy link
Copy Markdown
Contributor Author

bitloi commented Mar 26, 2026

Appreciate your review and support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixes Related to suggested fixes for violations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FURB142 fix should parenthesize generator expressions

3 participants