Improve comprehension line break beheavior#5680
Conversation
|
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
| let comments = f.context().comments().clone(); | ||
|
|
||
| write!(f, [in_parentheses_only_group(&left.format())])?; | ||
| let inner = format_with(|f| { |
There was a problem hiding this comment.
No change other than that this gets all wrapped in an in_parentheses_only_group
| for ( | ||
| ccccccccccccccccccccccccccccccccccccccc, | ||
| ddddddddddddddddddd, | ||
| [eeeeeeeeeeeeeeeeeeeeee, fffffffffffffffffffffffff], | ||
| ) in eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd |
There was a problem hiding this comment.
Black doesn't insert parentheses here. I'll look into this next
There was a problem hiding this comment.
yep i think that black remove tuple parentheses here same as for statements. i'd expect this is the same case for if-else expressions being analogous to if statements
71a4aa2 to
7357591
Compare
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinuxWindows |
| Spacer(target), | ||
| target.format(), | ||
| soft_line_break_or_space(), | ||
| in_spacer, |
There was a problem hiding this comment.
would the macros rules allow inlining the in_space as if expression?
There was a problem hiding this comment.
I don't think so because space and soft_line_break_or_space return different structs.
| i | ||
| in | ||
| aitertools._async_map(self.async_inc, arange(8), batch_size=3) | ||
| async for i in aitertools._async_map( |
| - and b != 9 # fmt: skip | ||
| + and b | ||
| + != 9 # fmt: skip | ||
| + and b != 9 # fmt: skip |
| for ( | ||
| ccccccccccccccccccccccccccccccccccccccc, | ||
| ddddddddddddddddddd, | ||
| [eeeeeeeeeeeeeeeeeeeeee, fffffffffffffffffffffffff], | ||
| ) in eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd |
There was a problem hiding this comment.
yep i think that black remove tuple parentheses here same as for statements. i'd expect this is the same case for if-else expressions being analogous to if statements
a9c9dd5 to
3fbd025
Compare
7357591 to
3bce23a
Compare
3fbd025 to
30e7756
Compare
3bce23a to
e83b302
Compare
e83b302 to
6e5dc7b
Compare
|
@MichaReiser merged this pull request with Graphite. |

Summary
This PR improves the Black compatibility when it comes to breaking comprehensions.
We want to avoid line breaks before the target and
inwhenever possible. Furthermore,if X is not Noneshould be grouped together, similar to other binary like expressionsTest Plan
cargo test