-
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
Format implicit string continuation #5328
Conversation
Current dependencies on/for this PR: This comment was auto-generated by Graphite. |
cc6019d
to
affb113
Compare
@@ -10,6 +11,14 @@ impl FormatNodeRule<StmtExpr> for FormatStmtExpr { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. BenchmarkLinux
Windows
|
@@ -10,6 +11,14 @@ impl FormatNodeRule<StmtExpr> for FormatStmtExpr { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_quote
with 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.