question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

yapf --style=pep8 continuation line may not distinguish itself from next line

See original GitHub issue

The following code:

class Foo(object):

    def bar(self):
        if self.solo_generator is None and len(
                self.generators + self.next_batch) == 1:
            pass

reformats as

class Foo(object):
    def bar(self):
        if self.solo_generator is None and len(
            self.generators + self.next_batch) == 1:
            pass

Which the pep8 error checker says “E125 continuation line with same indent as next logical line” to

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tschaubcommented, Jul 21, 2020

It looks to me like this is still an issue when dedent_closing_brackets: true is used.

This code aligns with PEP 8 recommendations:

if (
    0X000000000000000000000000 or 0X000000000000000000000000
) and (
    0X000000000000000000000000 or 0X000000000000000000000000
):
    pass

Passing it through yapf --style "{based_on_style: pep8, dedent_closing_brackets: true}" check.py yields this:

if (0X000000000000000000000000 or 0X000000000000000000000000
    ) and (0X000000000000000000000000 or 0X000000000000000000000000):
    pass

Which doesn’t align with PEP 8’s indentation recommendation and raises flake8’s “continuation line with same indent as next logical line” E125 error.

0reactions
joaoportelacommented, Oct 5, 2015

I’m having the same issue, is this fixed in version 0.3.1?

$ yapf --version
yapf 0.3.1

$ yapf datasync/server.py --diff
--- datasync/server.py  (original)
+++ datasync/server.py  (reformatted)
@@ -82,7 +82,7 @@
def validate_message_structure(message):
    """Check if the message contains all keys."""
    if ("op" in message and "args" in message and "api" in message and
-            "orig" in message):
+        "orig" in message):
        return True
    else:
        return False
Read more comments on GitHub >

github_iconTop Results From Across the Web

Continuation line with same indent as next logical line (E125)
Continuation lines should not be indented at the same level as the next logical line. Instead, they should be indented to one more...
Read more >
Diff - platform/external/yapf - Google Git
+- A non-multiline string may have newlines if it contains continuation markers + itself. Don't add a newline after the string when retaining...
Read more >
Define functions with too many arguments to abide by PEP8 ...
Personally I detest this approach, in which continuation lines have leading whitespace that doesn't correspond to any real indentation level. My approach would...
Read more >
How to Write Beautiful Python Code With PEP 8 - Real Python
PEP 8 outlines ways to allow statements to run over several lines. Python will assume line continuation if code is contained within parentheses,...
Read more >
Django: Reformatted code with Black | Hacker News
It even has a "black" compatible profile that line spits along black's defaults. ... Once the code is initially migrated (which should not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found