Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

less brackets than black in multiline assert #8388

Open
peterjc opened this issue Oct 31, 2023 · 2 comments
Open

less brackets than black in multiline assert #8388

peterjc opened this issue Oct 31, 2023 · 2 comments
Labels
documentation Improvements or additions to documentation formatter Related to the formatter

Comments

@peterjc
Copy link

peterjc commented Oct 31, 2023

Excerpt from https://github.com/peterjc/thapbi-pict/blob/v1.0.3/thapbi_pict/prepare.py formatted by black (e.g. black version 23.10.1):

assert (
    parse_flash_stdout(
        """\
...
[FLASH] Read combination statistics:
[FLASH]     Total pairs:      6105
[FLASH]     Combined pairs:   5869
...
"""
    )
    == (6105, 5869)
)

Output from ruff version 1.0.3 (which black reverts to the above):

assert parse_flash_stdout(
    """\
...
[FLASH] Read combination statistics:
[FLASH]     Total pairs:      6105
[FLASH]     Combined pairs:   5869
...
"""
) == (6105, 5869)

I prefer the ruff version (one less level of indentation and no redundant parenthesis).

I'm unsure if this is https://github.com/astral-sh/ruff/blob/main/docs/formatter/black.md#call-chain-calls-break-differently or #8180 or #8331.

@stinodego
Copy link
Contributor

I noticed this too in the Polars test suite. It's one of the nice improvements of the ruff formatter, in my opinion! Though I'm not sure it's intended.

@MichaReiser
Copy link
Member

Thanks for reporting. We're glad you like it :)

This is related to #6938, which we need to document properly. It is a partial implementation of Black's improved multiline string handling that we got for free, and fixing it backward felt like wasted work, considering how rare it is. Which is why we kept it. I'll keep this issue open to track the documentation of the deviation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation formatter Related to the formatter
Projects
None yet
Development

No branches or pull requests

3 participants