Skip to content

Consider not breaking line on outermost parenthesis #500

@cdeil

Description

@cdeil

First of all - thank you for making black!
I'm applying it to my main project (Gammapy) today.

There are a few examples where I think that black gives non-ideal results, and wanted to mention them here. If those have been discussed before, I apologise, please just close this issue.

I think this is nice:

things = OrderedDict([
    ('ham', 'spam'),
    ('bla bla bla bla', 'some more text here'),
])

and putting [ and ] on a separate line like black does is not an improvement:

things = OrderedDict(
    [
        ("ham", "spam"),
        ("bla bla bla bla", "some more text here"),
    ]
)

I read through the black description, and see that this is intended behaviour to always add line breaks on the outermost parenthesis. Is it possible / up for debate to change this in some cases?

This is another case:

text  = """
Hello hallo
allo allo
"""[1:-1]

where black gives this output:

text = """
Hello hallo
allo allo
"""[
    1:-1
]

and I think the input formatting is better readable than the black output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    R: duplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions