-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Black shouldn't merge multi-line string when last character on the line is '\n' #1540
Comments
Looks like a duplicate of #1467 (not sure, this should stay open for now). IMHO, I wouldn't exactly trust the online Black demo at https://black.now.sh, from my experience it seems unreliable for certain reproducing conditions. |
@Conchylicultor With the introduction of #1132, the segments are now merged together. |
But I don't want black to merge the string. Black should respect the
Is more readable than:
As code formatting match the way the string is displayed. |
@Conchylicultor The case described by this issue is a bit different than #1467, since #1467 relates directly to #1132, whereas this issue does not. I'm not saying that black shouldn't act the way you describe in this isue and the way described in #1467. I'm just pointing out that the code changes necessary in the two cases are very different. |
@bbugyi200, thank you for the clarification. I understand now that #1132 wasn't trying to solve this issue. |
As a workaround you can put explicit |
using explicit "+" still results in the strings merging into 1 (using version=black, 21.12b0) |
My personal opinion is that this issue should be closed and #1467 should remain open. Moreover, I think that this issue's example should continue to be formatted as it is currently (when the |
This issue is kind of popularizes use of "+" for string concatenation for me. 🥲 a = (
"&SortByValue=priority&SortByOrder=asc"
+ "&IndexToStartPaging={3}"
+ "&NumberOfElementsToShow={2}"
+ "&CacheDurationMinutes=0"
+ "&AllowAlternativeResults=false"
) |
Describe the style change
It may be related to #1467, but it seems #1467 is fixed when trying on https://black.now.sh/ while this one still fail.
Currently, string split in multiple lines are merged together.
Input:
When the last character of the line is a
\n
, the code formatting match how the string will be displayed:Examples in the current Black style
Black merge all lines together, while keeping segments separated, which hurts readability:
Desired style
Black shouldn't merge the lines together and keep the original formatting:
The text was updated successfully, but these errors were encountered: