Skip to content

Commit

Permalink
Tweak breaking groups for comprehensions
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Aug 3, 2023
1 parent 5f225b1 commit 863e98d
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,19 @@
k: str(v)
for vvvvvvvvvvvvvvvvvvvvvvv in value if str(v) not in self.choices.field.empty_values
}

a = {
k: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
}

a = {
k: [1, 2, 3,]
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
}

aaaaaaaaaaaaaaaaaaaaa = {
k: o for o in self.registry.values if o.__class__ is not ModelAdmin
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,19 @@
# trailing
)
)

a = (
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
)

a = (
[1, 2, 3,]
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
)

aaaaaaaaaaaaaaaaaaaaa = (
o for o in self.registry.values if o.__class__ is not ModelAdmin
)
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,20 @@

# Tuples with BinOp
[i for i in (aaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccc)]
[(aaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccc) for i in b]
[(aaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccc) for i in b]

a = [
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
]

a = [
[1, 2, 3,]
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
]

aaaaaaaaaaaaaaaaaaaaa = [
o for o in self.registry.values if o.__class__ is not ModelAdmin
]
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl FormatNodeRule<ExprDictComp> for FormatExprDictComp {
space(),
value.format(),
soft_line_break_or_space(),
group(&joined)
&joined
)),
"}"
)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,18 @@ impl FormatNodeRule<ExprGeneratorExp> for FormatExprGeneratorExp {
if self.parentheses == GeneratorExpParentheses::StripIfOnlyFunctionArg {
write!(
f,
[
group(&elt.format()),
soft_line_break_or_space(),
group(&joined),
]
[group(&elt.format()), soft_line_break_or_space(), &joined]
)
} else {
write!(
f,
[parenthesized(
"(",
&format_args!(
&group(&format_args!(
group(&elt.format()),
soft_line_break_or_space(),
group(&joined)
),
&joined
)),
")"
)]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl FormatNodeRule<ExprListComp> for FormatExprListComp {
&group(&format_args![
group(&elt.format()),
soft_line_break_or_space(),
group(&joined)
&joined
]),
"]"
)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl FormatNodeRule<ExprSetComp> for FormatExprSetComp {
&group(&format_args!(
group(&elt.format()),
soft_line_break_or_space(),
group(&joined)
&joined
)),
"}"
)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ selected_choices = {
k: str(v)
for vvvvvvvvvvvvvvvvvvvvvvv in value if str(v) not in self.choices.field.empty_values
}
a = {
k: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
}
a = {
k: [1, 2, 3,]
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
}
aaaaaaaaaaaaaaaaaaaaa = {
k: o for o in self.registry.values if o.__class__ is not ModelAdmin
}
```

## Output
Expand Down Expand Up @@ -241,6 +257,26 @@ selected_choices = {
for vvvvvvvvvvvvvvvvvvvvvvv in value
if str(v) not in self.choices.field.empty_values
}
a = {
k: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
}
a = {
k: [
1,
2,
3,
]
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
}
aaaaaaaaaaaaaaaaaaaaa = {
k: o for o in self.registry.values if o.__class__ is not ModelAdmin
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ len(
# trailing
)
)
a = (
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
)
a = (
[1, 2, 3,]
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
)
aaaaaaaaaaaaaaaaaaaaa = (
o for o in self.registry.values if o.__class__ is not ModelAdmin
)
```

## Output
Expand Down Expand Up @@ -62,6 +78,26 @@ len(
for b in c
# trailing
)
a = (
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
)
a = (
[
1,
2,
3,
]
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
)
aaaaaaaaaaaaaaaaaaaaa = (
o for o in self.registry.values if o.__class__ is not ModelAdmin
)
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,24 @@ selected_choices = [
# Tuples with BinOp
[i for i in (aaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccc)]
[(aaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccc) for i in b]```
[(aaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccc) for i in b]
a = [
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
]
a = [
[1, 2, 3,]
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
]
aaaaaaaaaaaaaaaaaaaaa = [
o for o in self.registry.values if o.__class__ is not ModelAdmin
]
```
## Output
```py
Expand Down Expand Up @@ -141,6 +158,26 @@ selected_choices = [
)
for i in b
]
a = [
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
]
a = [
[
1,
2,
3,
]
for f in bbbbbbbbbbbbbbb
if f not in ccccccccccc
]
aaaaaaaaaaaaaaaaaaaaa = [
o for o in self.registry.values if o.__class__ is not ModelAdmin
]
```
Expand Down

0 comments on commit 863e98d

Please sign in to comment.