Skip to content

[ruff] Parenthesize generator expressions in f-strings (RUF010)#19434

Merged
ntBre merged 3 commits intoastral-sh:mainfrom
danparizher:fix-19433
Jul 30, 2025
Merged

[ruff] Parenthesize generator expressions in f-strings (RUF010)#19434
ntBre merged 3 commits intoastral-sh:mainfrom
danparizher:fix-19433

Conversation

@danparizher
Copy link
Copy Markdown
Contributor

Summary

Fixes #19433

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 20, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre ntBre added bug Something isn't working fixes Related to suggested fixes for violations labels Jul 20, 2025
@ntBre ntBre self-requested a review July 24, 2025 13:07
Comment thread crates/ruff_linter/src/rules/ruff/rules/explicit_f_string_type_conversion.rs Outdated
@danparizher danparizher requested a review from ntBre July 30, 2025 00:19
Copy link
Copy Markdown
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thanks!

Comment thread crates/ruff_linter/src/rules/ruff/rules/explicit_f_string_type_conversion.rs Outdated
}

// Check precedence for other expressions
needs_paren(OperatorPrecedence::from_expr(arg))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is fine for now, but I wonder if a better fix would be to handle unparenthesized generator expressions differently in OperatorPrecedence::from_expr. It doesn't really seem to fit into the rest of the precedence hierarchy, though.

@ntBre ntBre changed the title [ruff] Fix RUF010 to parenthesize generator expressions in f-strings [ruff] Parenthesize generator expressions in f-strings (RUF010) Jul 30, 2025
@ntBre ntBre enabled auto-merge (squash) July 30, 2025 14:59
@ntBre ntBre merged commit e593761 into astral-sh:main Jul 30, 2025
34 checks passed
@danparizher danparizher deleted the fix-19433 branch July 30, 2025 15:12
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.

RUF010 fix should parenthesize generator expressions

2 participants