-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Disallow single-line implicit concatenated strings #13928
Disallow single-line implicit concatenated strings #13928
Conversation
...ormatter/tests/snapshots/black_compatibility@cases__preview_long_strings__regression.py.snap
Outdated
Show resolved
Hide resolved
|
d9bec17
to
ba5d612
Compare
ba5d612
to
08de539
Compare
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 think this is a smart change. We should document it in the Black deviations though.
Thanks for the feedback. I plan to document the deviations as part of promoting the new style guide. |
Summary
Fixes #8272
The formatter is incompatible with
ISC001
because it can introduce new single-line implicit concatenated strings if all parts fit on the line. The new implicit concatenated string formatting style already addresses this incompatibility for regular strings and most f-string but not for triple quoted strings and raw strings.This PR proposes to change the formatter style to never collapse the parts of an implicit concatenated string onto a single line unless it has been formatted on a single line by the author.
Is preserved as is because the author wrote the implicit concatenated string on a single line and it fits. The source i already incompatible with ISC001.
The current style collapses this string to match the example above. The style proposed in this PR preserves the multiline formatting in this case because there's a line break between the two parts.
Preview gating
It's technically not required to gate this change behind preview because it doesn't change the formatting of any existing code. But it fits nicely into the other implicit concatenated work that we've been doing and the new implicit concatenated string formatting also largely mitigates that this leads to slightly less consistent formatting (because it's up to the author whether the string remains multiline or not)
Test Plan
Added tests