Format implicit string continuation#5328
Conversation
|
Current dependencies on/for this PR: This comment was auto-generated by Graphite. |
cc6019d to
affb113
Compare
| fn fmt_fields(&self, item: &StmtExpr, f: &mut PyFormatter) -> FormatResult<()> { | ||
| let StmtExpr { value, .. } = item; | ||
|
|
||
| if let Some(constant) = value.as_constant_expr() { |
There was a problem hiding this comment.
It seems that StmtExpr is the only one where we don't want to break string continuations. So I added an explicit exclude.
There was a problem hiding this comment.
Using implicit concatenations on statement level feels strange to me, do we have any examples of that in the wild
There was a problem hiding this comment.
Hmm I don't know. Is there a good way finding this out using your scripts? This was probably the hardest part of this PR (figuring out the rule when this is happening), which is why I would prefer not removing it until we're sure that we don't need it. I could add a TODo to experiment removing it once we have a ecosystem check in place.
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinuxWindows |
| fn fmt_fields(&self, item: &StmtExpr, f: &mut PyFormatter) -> FormatResult<()> { | ||
| let StmtExpr { value, .. } = item; | ||
|
|
||
| if let Some(constant) = value.as_constant_expr() { |
There was a problem hiding this comment.
Using implicit concatenations on statement level feels strange to me, do we have any examples of that in the wild
affb113 to
cae5757
Compare

Summary
This Branch adds support for formatting implicit string continuations. We could probably come up with something faster that combines the
preferred_quotewith the detection of implicit continuation but I don't think that it's worth optimizing just yet.Test Plan
I added new unit tests because black's test suite has not a single implicit continuation.
I ran the stability check against the cpython project.