Skip to content

Address autopep8 overriding pycodestyle's continued_indentation #719

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

Merged
merged 7 commits into from
Dec 24, 2019

Conversation

johnhany97
Copy link
Member

Before this PR

Given a Python file like:

def hello():
    print("Python", ("Hello",
                                     "World"))

The diagnostics report of pycodestyle is:

[{'source': 'pycodestyle', 'range': {'start': {'line': 2, 'character': 37}, 'end': {'line': 2, 'character': 47}}, 'message': 'E127 21', 'code': 'E127', 'severity': 2}]

Root cause & Description

While the error code, E127, is expected, this is not the expected error message.
This is because autopep8 overrides pycodestyle's implementation of continued_indentation which is the check used to determine this error code, among others. autopep8's implementation however returns a different thing than what we expect out of the pycodestyle implementation, leading to a scenario where the diagnostics report contains an unuseful error message.

After this PR

The output is as expected:

[{'source': 'pycodestyle', 'range': {'start': {'line': 2, 'character': 37}, 'end': {'line': 2, 'character': 47}}, 'message': 'E127 continuation line over-indented for visual indent', 'code': 'E127', 'severity': 2}]

@ccordoba12 ccordoba12 added this to the 0.31.4 milestone Dec 24, 2019
Copy link
Contributor

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @johnhany97!

@ccordoba12 ccordoba12 merged commit 0114c6c into palantir:develop Dec 24, 2019
@afflux
Copy link

afflux commented Mar 27, 2020

Unfortunately, this change breaks formatting when a document has continuation lines.

Try formatting this:

def foo():
    print('asdf',
    file=None
    )

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

Successfully merging this pull request may close these issues.

3 participants