psf / black

The uncompromising Python code formatter
https://black.readthedocs.io/en/stable/
MIT License
38.3k stars 2.42k forks source link

string_processing: Better whitespace allocation for an assert statement #3663

Open st-pasha opened 1 year ago

st-pasha commented 1 year ago

Describe the style change

Strange indentation of a long assert statement, in --preview (it works correctly in the stable branch).

Examples in the current (preview) Black style

assert (
    result
    == "Lorem ipsum dolor sit amet,\n"
    "consectetur adipiscing elit,\n"
    "sed doeiusmod tempor incididunt\n"
)

Desired style

assert result == (
    "Lorem ipsum dolor sit amet,\n"
    "consectetur adipiscing elit,\n"
    "sed doeiusmod tempor incididunt\n"
)

Additional context

Similar to #3409

st-pasha commented 1 year ago

I think a reasonable rule for the assert statement could be something like this: