Skip to content

E124 is incorrect #10

@munk

Description

@munk

E124 says:

Closing brackets should match the indentation of the opening bracket.

Anti-pattern

result = function_that_takes_arguments('a', 'b', 'c',
                                       'd', 'e', 'f',
)

Best practice

result = function_that_takes_arguments('a', 'b', 'c',
                                       'd', 'e', 'f',
                                       )

But the pep8 spec says:

The closing brace/bracket/parenthesis on multiline constructs may either line up under the first non-whitespace character of the last line of list, as in:

my_list = [
    1, 2, 3,
    4, 5, 6,
    ]
result = some_function_that_takes_arguments(
    'a', 'b', 'c',
    'd', 'e', 'f',
    )

or it may be lined up under the first character of the line that starts the multiline construct, as in:

my_list = [
    1, 2, 3,
    4, 5, 6,
]
result = some_function_that_takes_arguments(
    'a', 'b', 'c',
    'd', 'e', 'f',
)

This rule should allow closing brackets to either align with the opening bracket or the first character of the multiline construct. The explanation should be updated to exclude the following example as an anti-pattern instead.

Anti-pattern

result = function_that_takes_arguments('a', 'b', 'c',
                                       'd', 'e', 'f',
                                        )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions