Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad comment indentation #456

Closed
advance512 opened this issue Sep 18, 2017 · 4 comments
Closed

Bad comment indentation #456

advance512 opened this issue Sep 18, 2017 · 4 comments

Comments

@advance512
Copy link

        businessManager = Business(
            businessManagerId, api=defaultApi
        ).remote_read(
            fields=[
                Business.Field.id,
                Business.Field.name,
                Business.Field.link,
                # Business.Field.timezone_id,
            ]
        )

gets formatted to:

        businessManager = Business(
            businessManagerId, api=defaultApi
        ).remote_read(
            fields=[
                Business.Field.id,
                Business.Field.name,
                Business.Field.link,
    # Business.Field.timezone_id,
            ]
        )

Note the comment. This triggers "E122 continuation line missing indentation or outdented" from flake8.

@ritiek
Copy link

ritiek commented Sep 18, 2017

What yapf version are you using? Mine is yapf 0.17.0.

It changes the below input

# random function
def test():
    pass
# a test
if 3==3:
    if 4==4:
        businessManager = Business(
            businessManagerId, api=defaultApi
        ).remote_read(
            fields=[
                Business.Field.id,
                Business.Field.name,
                Business.Field.link,
                # Business.Field.timezone_id,
            ]
        )

to

# random function
def test():
    pass


# a test
if 3 == 3:
    if 4 == 4:
        businessManager = Business(
            businessManagerId, api=defaultApi).remote_read(
                fields=[
                    Business.Field.id,
                    Business.Field.name,
                    Business.Field.link,
                    # Business.Field.timezone_id,
                ])

which I believe is the expected formatting.

@bwendling
Copy link
Member

I get the same as @ritiek running against ToT.

@woodmd
Copy link

woodmd commented Jun 7, 2018

I'm seeing the same issue as @advance512 using the latest version of yapf (0.22.0) and python 2.7.14. If I set the style on the command-line (e.g. with yapf --style=pep8) the formatting is as expected but when running without arguments I get wrong indentation for comments. I'm configuring my default style using a setup.cfg with the following:

[yapf]
based_on_style = pep8
spaces_before_comment = 4
split_before_logical_operator = true
column_limit = 100

@zheolong
Copy link

@advance512 same issue, my yapf version is 0.30.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants