-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
T: styleWhat do we want Blackened code to look like?What do we want Blackened code to look like?
Description
Describe the style change
#3440 (closing #620 and #808) improved handling of long expressions in dict values by putting them in parentheses, but the same values in function arguments aren't always handled nicely.
Examples in the current Black style
dict(
key_key_key_key=a_long_long_long_long_long
* b_long_long_long_long_long
/ 100.0
)
dict(
key_key_key_key_key_key_key_key_key=lambda: some_very_long_function_name(
x, y, z
)
)Desired style
dict(
key_key_key_key=(
a_long_long_long_long_long * b_long_long_long_long_long / 100.0
)
)
dict(
key_key_key_key_key_key_key_key_key=(
lambda: some_very_long_function_name(x, y, z)
)
)Additional context
The above problem surprisingly isn't present when the expression is the ternary operator. I found this related issue: #2248, and I think it could be closed now, as on the --preview on main it's fixed.
Here's a comparison of some structures where formatting is good and not good:
Without preview enabled, cases A-J excluding E are ugly, with preview enabled only C, D, I and J are ugly (and these are the examples presented above).
matthewlloyd, chrisrink10 and obaltian
Metadata
Metadata
Assignees
Labels
T: styleWhat do we want Blackened code to look like?What do we want Blackened code to look like?