Describe the style change
When splitting long string literals in Black's --preview Improved string processing style, add parentheses around implicit string concatenations to increase readability in certain contexts.
"certain contexts" include:
- Function parameters
- Sequence elements
Examples of unformatted code
flash(
'None of the email addresses or domains you entered are valid',
'error',
)
some_list = [
' lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua Ut enim ad minim',
' veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo',
]
Examples in the current Black style
flash(
'None of the email addresses or domains you entered'
' are valid',
'error',
)
some_list = [
" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor"
" incididunt ut labore et dolore magna aliqua Ut enim ad minim",
" veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo",
]
Desired style
flash(
(
'None of the email addresses or domains you entered'
' are valid'
),
'error',
)
some_list = [
(
" lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor"
" incididunt ut labore et dolore magna aliqua Ut enim ad minim"
),
" veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo",
]
Additional context
This issue was raised originally in #2188 (comment). Per @JelleZijlstra, I'm starting a new issue separately here to track the work.
The "certain contexts" list isn't exhaustive. I plan to read the code and play around with an implementation, then report back here.
Describe the style change
When splitting long string literals in Black's
--previewImproved string processing style, add parentheses around implicit string concatenations to increase readability in certain contexts."certain contexts" include:
Examples of unformatted code
Examples in the current Black style
Desired style
Additional context
This issue was raised originally in #2188 (comment). Per @JelleZijlstra, I'm starting a new issue separately here to track the work.
The "certain contexts" list isn't exhaustive. I plan to read the code and play around with an implementation, then report back here.