Skip to content

Reformatted continuation lines have the same indent as the following line #196

Description

@malcolmr

It's possible for yapf to format a continuation line so that the indentation is the same as the following line. (This is similar to #21.)

Given:

class Foo(object):
    def __init__(
            self, aaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbb, ccccccccccccccccc,
            ddddddddddd):
        self.aaaaaaaaaaaa = aaaaaaaaaaaa

yapf 0.5.0 produces:

class Foo(object):
    def __init__(
        self, aaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbb, ccccccccccccccccc,
        ddddddddddd):
        self.aaaaaaaaaaaa = aaaaaaaaaaaa
$ pep8 foo.py
bar.py:4:5: E125 continuation line with same indent as next logical line

Interestingly, unwrapping the def line first causes yapf to produce the following, which is fine:

class Foo(object):
    def __init__(self, aaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbb, ccccccccccccccccc,
                 ddddddddddd):
        self.aaaaaaaaaaaa = aaaaaaaaaaaa

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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