-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve comprehension line break beheavior #5680
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
@@ -33,36 +33,40 @@ impl FormatNodeRule<ExprCompare> for FormatExprCompare { | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black doesn't insert parentheses here. I'll look into this next
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. BenchmarkLinux
Windows
|
target.format(), | ||
soft_line_break_or_space(), | ||
in_spacer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would the macros rules allow inlining the in_space
as if expression?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that looks much nicer
a, b, c = 3, 4, 5 | ||
if ( | ||
a == 3 | ||
- and b != 9 # fmt: skip | ||
+ and b | ||
+ != 9 # fmt: skip | ||
+ and b != 9 # fmt: skip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this, too
for ( | ||
ccccccccccccccccccccccccccccccccccccccc, | ||
ddddddddddddddddddd, | ||
[eeeeeeeeeeeeeeeeeeeeee, fffffffffffffffffffffffff], | ||
) in eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
in
whenever possible. Furthermore,if X is not None
should be grouped together, similar to other binary like expressionsTest Plan
cargo test