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

Format rule to keep together }, { for list of objects #11336

Closed
darowny opened this issue May 8, 2024 · 1 comment
Closed

Format rule to keep together }, { for list of objects #11336

darowny opened this issue May 8, 2024 · 1 comment
Labels
question Asking for support or clarification

Comments

@darowny
Copy link

darowny commented May 8, 2024

Is there a setting or a rule that will keep this style of formatting ? I mean keeping }, { together and then hugging }] at the end?

trans = [{
    'first': Stuff,
    'second': Other,
    'third': Blah,
    'fourth': Sth
}, {
    'first': Stuff,
    'second': Other,
    'third': Blah,
    'fourth': Sth
}, {
    'first': Stuff,
    'second': Other,
    'third': Blah,
    'fourth': Sth
}]

I tried 0.3.4 and 0.4.3 ruff for this, with enabled preview, shouldn't it keep hugging braces and brackets ?
Related discussion I think

@darowny darowny changed the title Format rule for keeping Format rule to keep together }, { for list of objects May 8, 2024
@MichaReiser MichaReiser added the question Asking for support or clarification label May 8, 2024
@MichaReiser
Copy link
Member

Hi @darowny

No, there's no such formatter setting.

The hugging preview style only applies if the array (or dict or set) is the only argument in a function call or the only content of a prenthesized expression

trans = call([
    {
        "first": Stuff,
        "second": Other,
        "third": Blah,
        "third": Blah,
    }
])


trans = a + ([
    {
        "first": Stuff,
        "second": Other,
        "third": Blah,
        "third": Blah,
    }
])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

2 participants