Skip to content

E131 applies inconsistently with nested calls #953

Open
@mattdicarlo

Description

@mattdicarlo

I often use an indentation format like this for long method chains with something like SQLAlchemy, which seems to be acceptable according to my reading of PEP8 and doesn't raise any errors when pycodestyle is run:

rows = db.engine.execute(
    table.select()
         .where(table.c.column1 == 'something')
         .where(table.c.column2.is_(None))
         .order_by(table.c.column3)
         .limit(5)
)

However, if the name of the variable being assigned to is a particular length, E131 - continuation line unaligned for hanging indent is raised:

aaaaaaaa = db.engine.execute(
    table.select()
         .where(table.c.column1 == 'something')  # E131
         .where(table.c.column2.is_(None))       # E131
         .order_by(table.c.column3)              # E131
         .limit(5)                               # E131
)

It seems to be related to having the = operator aligned with the indented lines? Adding just a single character to the left side of the assignment will remove the E131.

aaaaaaaab = db.engine.execute(
    table.select()
         .where(table.c.column1 == 'something')
         .where(table.c.column2.is_(None))
         .order_by(table.c.column3)
         .limit(5)
)

Is this an issue in pycodestyle, or do I just not understand what's going on here?

$ pycodestyle --version
2.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions