-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
F: parenthesesToo many parentheses, not enough parentheses, and so on.Too many parentheses, not enough parentheses, and so on.F: stringsRelated to our handling of stringsRelated to our handling of stringsS: acceptedThe changes in this design / enhancement issue have been accepted and can be implementedThe changes in this design / enhancement issue have been accepted and can be implementedT: styleWhat do we want Blackened code to look like?What do we want Blackened code to look like?
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
F: parenthesesToo many parentheses, not enough parentheses, and so on.Too many parentheses, not enough parentheses, and so on.F: stringsRelated to our handling of stringsRelated to our handling of stringsS: acceptedThe changes in this design / enhancement issue have been accepted and can be implementedThe changes in this design / enhancement issue have been accepted and can be implementedT: styleWhat do we want Blackened code to look like?What do we want Blackened code to look like?