E126 false positive #144

Closed
jianli opened this Issue Dec 18, 2012 · 3 comments

Projects

None yet

4 participants

@jianli
jianli commented Dec 18, 2012

Unresolved issue from #138. I'm creating a new issue since I'm unable to reopen that issue.

E126 continuation line over-indented for hanging indent

{
    1:
        999999 if True
        else 0,
}

@florentx wrote that this would be better written with parentheses.

I responded:

what's the rationale behind rewriting [it] with parentheses? The parentheses aren't syntactically necessary, and they don't make the expression more readable either.

@florentx
Collaborator

I missed your reply on #138, sorry.

What the message suggests is to use the syntax below without additional indentation

    {
        1:
        999999 if True
        else 0,
    }

... which is compliant with the style guide.

And the other style I proposed is to add () to mark explicitly that you want to align the value on its own column, not the same column as the key.

    {
        1: (999999 if True
            else 0),
    }

Both syntaxes are valid.
But I don't see any obvious fix to support the exact syntax you proposed.

The ultimate solution is to simply --ignore E126 if you disagree with this checker.

@dzinxed
dzinxed commented Feb 11, 2013

I agree that it's a false positive. The problem is more obvious if you have e.g. a dict literal with key-value pairs that would not fit into a single (80-char) line at all:

def func():
    foo = {
        u'quite.a.long.key':
            u'a.very.long.value.that.would.not.fit.into.a.single.line'
    }

pep8.py signals an E126 here.

@aclewis182

@dzinxed I'm seeing this very issue right now.

@florentx florentx closed this in 0308f2f Mar 24, 2014
@florentx florentx added bug and removed needs patch labels Mar 24, 2014
@florentx florentx added this to the 1.5.0 milestone Mar 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment