Skip to content

Indexing square brackets split on 3 lines #3068

@ikamensh

Description

@ikamensh

Describe the style change
I have an assert statement that checks a condition on the last element in an array. To me what black does to the statement makes it less readable:

assert self.ref_transitions[-1].terminal.all(), "Last ref transition must be terminal."

Examples in the current Black style

assert self.ref_transitions[
    -1
].terminal.all(), "Last ref transition must be terminal."

Desired style

assert (
    self.ref_transitions[-1].terminal.all()
), "Last ref transition must be terminal."

# OR

assert self.ref_transitions[-1].terminal.all(), (
    "Last ref transition must be terminal."
)

Additional context

I think operation of taking [-1]th element is best visible with brackets and number grouped. Having to search them across a diagonal on 3 lines is tough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: linebreakHow should we split up lines?R: duplicateThis issue or pull request already existsT: styleWhat do we want Blackened code to look like?
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions