Describe the style change
I'm not sure if this is intended or not, but I noticed that sometimes in Black >=22.12.0 a trailing comma will trigger wrapping the concatenated string in parens, which otherwise wouldn't take place (if there was no trailing comma).
The suggestion is to make it so that the presence of the trailing comma would have no bearing on whether the concatenated string will or not be wrapped in parens.
PS: In this particular case the trailing commas are added's by Ruff's COM rules: https://beta.ruff.rs/docs/rules/#flake8-commas-com
Examples in the current Black style
(1) No trailing comma
Original string:
class Allow(NamedTuple):
message: str
Allow(
"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 consequat. Duis aute irure dolor in reprehenderit in"
" voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat"
" cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
)
Stays as is after applying Black 23.1.0 formatting.
(2) Trailing comma
Original string:
class Allow(NamedTuple):
message: str
Allow(
"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 consequat. Duis aute irure dolor in reprehenderit in"
" voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat"
" cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
)
Gets reformatted to this by Black 23.1.10:
class Allow(NamedTuple):
message: str
Allow(
(
"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 consequat. Duis aute irure dolor in"
" reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur"
" sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id"
" est laborum."
),
)
Desired style
No wrapping parens would be added – neither in (1) No trailing comma nor in (2) Trailing comma.
I.e. this string would be legal Black formatting and would not be changed:
class Allow(NamedTuple):
message: str
Allow(
"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 consequat. Duis aute irure dolor in reprehenderit in"
" voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat"
" cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
)
Additional context
Recently, Black has been wrapping code in parens to increase clarity (at the cost of sometimes adding indentation and extra lines, but it's a conscious tradeoff). For context, here are some recent relevant issues and PRs: #3292 and #3307 (shipped in 22.12.0 afaik) CC @yilei @felix-hilden @JelleZijlstra who were active on them
Describe the style change
I'm not sure if this is intended or not, but I noticed that sometimes in Black >=22.12.0 a trailing comma will trigger wrapping the concatenated string in parens, which otherwise wouldn't take place (if there was no trailing comma).
The suggestion is to make it so that the presence of the trailing comma would have no bearing on whether the concatenated string will or not be wrapped in parens.
PS: In this particular case the trailing commas are added's by Ruff's COM rules: https://beta.ruff.rs/docs/rules/#flake8-commas-com
Examples in the current Black style
(1) No trailing comma
Original string:
Stays as is after applying Black 23.1.0 formatting.
(2) Trailing comma
Original string:
Gets reformatted to this by Black 23.1.10:
Desired style
No wrapping parens would be added – neither in (1) No trailing comma nor in (2) Trailing comma.
I.e. this string would be legal Black formatting and would not be changed:
Additional context
Recently, Black has been wrapping code in parens to increase clarity (at the cost of sometimes adding indentation and extra lines, but it's a conscious tradeoff). For context, here are some recent relevant issues and PRs: #3292 and #3307 (shipped in 22.12.0 afaik) CC @yilei @felix-hilden @JelleZijlstra who were active on them