mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-22 20:45:11 +00:00
Tweak breaking groups for comprehensions (#6321)
## Summary Fixes some comprehension formatting by avoiding creating the group for the comprehension itself (so that if it breaks, all parts break on their own lines, e.g. the `for` and the `if` clauses). Closes https://github.com/astral-sh/ruff/issues/6063. ## Test Plan Bunch of new fixtures.
This commit is contained in:
parent
99baad12d8
commit
4d47dfd6c0
10 changed files with 166 additions and 9 deletions
|
@ -44,7 +44,7 @@ impl FormatNodeRule<ExprDictComp> for FormatExprDictComp {
|
|||
space(),
|
||||
value.format(),
|
||||
soft_line_break_or_space(),
|
||||
group(&joined)
|
||||
&joined
|
||||
)),
|
||||
"}"
|
||||
)]
|
||||
|
|
|
@ -60,7 +60,7 @@ impl FormatNodeRule<ExprGeneratorExp> for FormatExprGeneratorExp {
|
|||
leading_comments(dangling),
|
||||
group(&elt.format()),
|
||||
soft_line_break_or_space(),
|
||||
group(&joined),
|
||||
&joined
|
||||
]
|
||||
)
|
||||
} else {
|
||||
|
@ -69,11 +69,11 @@ impl FormatNodeRule<ExprGeneratorExp> for FormatExprGeneratorExp {
|
|||
[parenthesized_with_dangling_comments(
|
||||
"(",
|
||||
dangling,
|
||||
&format_args!(
|
||||
&group(&format_args!(
|
||||
group(&elt.format()),
|
||||
soft_line_break_or_space(),
|
||||
group(&joined)
|
||||
),
|
||||
&joined
|
||||
)),
|
||||
")"
|
||||
)]
|
||||
)
|
||||
|
|
|
@ -38,7 +38,7 @@ impl FormatNodeRule<ExprListComp> for FormatExprListComp {
|
|||
&group(&format_args![
|
||||
group(&elt.format()),
|
||||
soft_line_break_or_space(),
|
||||
group(&joined)
|
||||
&joined
|
||||
]),
|
||||
"]"
|
||||
)]
|
||||
|
|
|
@ -38,7 +38,7 @@ impl FormatNodeRule<ExprSetComp> for FormatExprSetComp {
|
|||
&group(&format_args!(
|
||||
group(&elt.format()),
|
||||
soft_line_break_or_space(),
|
||||
group(&joined)
|
||||
&joined
|
||||
)),
|
||||
"}"
|
||||
)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue