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

'Wrong hanging indent before block' False positive #2944

Closed
cysabi opened this issue Jun 3, 2019 · 11 comments
Closed

'Wrong hanging indent before block' False positive #2944

cysabi opened this issue Jun 3, 2019 · 11 comments
Labels

Comments

@cysabi
Copy link

cysabi commented Jun 3, 2019

Steps to reproduce

  1. ensure you are using 4 spaces for indent character
  2. paste this code:
for name, index in zip(
    [
        "foo:",
        "bar:",
    ],
    range(5),
):
    pass
  1. It will say there should be an extra 2 spaces in places it should not.

Current behavior

warnings

Expected behavior

No warnings

pylint --version output

pylint 2.3.1
astroid 2.2.5
Python 3.7.3 (default, May 11 2019, 00:38:04) 
[GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]
@PCManticore
Copy link
Contributor

Hi. Does it say that you need 2 extra spaces or 4? Can you paste the exact output you are receiving?

@PCManticore PCManticore added Bug 🪲 Needs reproduction 🔍 Need a way to reproduce it locally on a maintainer's machine labels Jul 7, 2019
@cysabi
Copy link
Author

cysabi commented Jul 11, 2019

Sorry, here is the exact output. And indeed it says 4.

example.py:2:0: C0330: Wrong hanging indentation before block (add 4 spaces).
    [
    ^   | (bad-continuation)
example.py:6:0: C0330: Wrong hanging indentation before block (add 4 spaces).
    range(5),
    ^   | (bad-continuation)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

This is after ignoring module docstring warnings.

@gyermolenko
Copy link
Contributor

gyermolenko commented Aug 11, 2019

I reproduced the output (pylint 2.4.0-dev0):

example.py:2:0: C0330: Wrong hanging indentation before block (add 4 spaces).
    [
    ^   | (bad-continuation)
example.py:6:0: C0330: Wrong hanging indentation before block (add 4 spaces).
    range(5),
    ^   | (bad-continuation)

So at least we can remove "also does not show error code for it" from the issue title )

@LeptoSpira you could probably do what it wants, add 4 spaces:

for name, index in zip(
        [
            "foo:",
            "bar:",
        ],
        range(5),
):
    pass

Checked both variants with pycodestyle - no warnings.
p.s. PyCharm reformats the code from issue into what I wrote above.

@cysabi
Copy link
Author

cysabi commented Aug 12, 2019

yapf formats it to without the 4 extra spaces, so I guess we should move this issue to the yapf repository?

@gyermolenko
Copy link
Contributor

yapf formats it to without the 4 extra spaces, so I guess we should move this issue to the yapf repository?

Unfortunately rules from pep8 in such case are not specific, and we don't have any solid arguments beside that

@cysabi
Copy link
Author

cysabi commented Aug 15, 2019

If that is so, I don't think the error should occur

@cysabi cysabi changed the title 'Wrong hanging indent before block' False positive, also does not show error code for it. 'Wrong hanging indent before block' False positive Aug 15, 2019
@lukaszdudek-silvair
Copy link

lukaszdudek-silvair commented Dec 4, 2019

Same thing happens with what black does with classes with many arguments:

class A:
    def __init__(
        self,
        many,
        long,
        arguments,
        passed,
        here
    )
    ...

pylint also complains about indentation here & wants 4 spaces to be added to each line with an argument.

@AWhetter AWhetter removed the Needs reproduction 🔍 Need a way to reproduce it locally on a maintainer's machine label Jan 30, 2020
@AWhetter
Copy link
Contributor

Thanks for the reproducible case @lukaszdudek-silvair

@bdrung
Copy link
Contributor

bdrung commented Jan 31, 2020

I stumbled over this issue after using black to format the code.

@iamstiil
Copy link

Is there any progress on this?

@Pierre-Sassoulas
Copy link
Member

bad-continuation has been removed in #3571, black or another formatter can help you with this better than Pylint

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

No branches or pull requests

8 participants