Skip to content

Long dict key with operators are oddly broken into multiple lines #3442

@yilei

Description

@yilei

Describe the style change

Examples in the current Black style

tests = [
    (
        BusinessHour(),
        {
            Timestamp("2014-07-04 15:00")
            + Nano(5): this_is_a_very_long_function("2014-07-04 16:00"),
            Timestamp("2014-07-04 16:00")
            + Nano(5): this_is_a_very_long_function("2014-07-04 16:00"),
            Timestamp("2014-07-04 16:00")
            - Nano(5): this_is_a_very_long_function("2014-07-04 16:00"),
        },
    ),
]

Desired style

tests = [
    (
        BusinessHour(),
        {
            Timestamp("2014-07-04 15:00") + Nano(5): (
                this_is_a_very_long_function("2014-07-04 16:00")
            ),
            Timestamp("2014-07-04 16:00") + Nano(5): (
                this_is_a_very_long_function("2014-07-04 16:00"),
            ),
            Timestamp("2014-07-04 16:00") - Nano(5): (
                this_is_a_very_long_function("2014-07-04 16:00")
            ),
        },
    ),
]

Additional context

This is an example found in #3440 while working on the dict value. I think the issue is that we don't treat : as a delimiter thus the "operators" are broken instead of :.

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: linebreakHow should we split up lines?S: acceptedThe changes in this design / enhancement issue have been accepted and can be implementedT: styleWhat do we want Blackened code to look like?

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions