2

I have a question regarding Pylint. I'm receiving the error "Wrong handling indentation" with "bad-continuation". I would like to know what I'm doing wrong. I've tried reading PEP8 to keep aligned with the function parenthesis but it did not work. Here's what I've tried: Thanks!

WALLACE_SP1[i] = rad_intercpt_wallace(
                                      [[K_SPECIES1[i],
                                      LAI_SPECIES1[i],
                                      SP_HEIGHT[i]],
                                      [K_SPECIES2[i],
                                      LAI_SPECIES2[i],
                                      SP_HEIGHT[i]]])[0]

WALLACE_SP1[i] = rad_intercpt_wallace(
                                      [[K_SPECIES1[i],
                                      LAI_SPECIES1[i],
                                      SP_HEIGHT[i]],
                                      [K_SPECIES2[i],
                                      LAI_SPECIES2[i],
                                      SP_HEIGHT[i]]]
                                      )[0]

WALLACE_SP1[i] = rad_intercpt_wallace([[K_SPECIES1[i], LAI_SPECIES1[i],
                                      SP_HEIGHT[i]], [K_SPECIES2[i],
                                      LAI_SPECIES2[i], SP_HEIGHT[i]]])[0]

WALLACE_SP1[i] = rad_intercpt_wallace([[K_SPECIES1[i], LAI_SPECIES1[i],
                                        SP_HEIGHT[i]],
                                        [K_SPECIES2[i], LAI_SPECIES2[i],
                                         SP_HEIGHT[i]]])[0]
1
  • Note that pylint sometimes requires impossible things: x spaces, not enough indentation; x+1 spaces, too much indentation. Commented Aug 4, 2014 at 18:11

3 Answers 3

4

Each interior [ requires its own consistent indentation. For example, LAI_SPECIES must be aligned with K_SPECIES (since they are both part of the same list).

WALLACE_SP1[i] = rad_intercpt_wallace(
    [[K_SPECIES1[i],
      LAI_SPECIES1[i],
      SP_HEIGHT[i]],
     [K_SPECIES2[i],
      LAI_SPECIES2[i],
      SP_HEIGHT[i]]])[0]

In the alternative:

WALLACE_SP1[i] = rad_intercpt_wallace(
    [[K_SPECIES1[i], LAI_SPECIES1[i], SP_HEIGHT[i]],
     [K_SPECIES2[i], LAI_SPECIES2[i], SP_HEIGHT[i]]])[0]
Sign up to request clarification or add additional context in comments.

Comments

0

This is the only way I've found for pep8 to stop complaining:

WALLACE_SP1[i] = rad_intercpt_wallace([[K_SPECIES1[i],
                                      LAI_SPECIES1[i],
                                      SP_HEIGHT[i]],
                                      [K_SPECIES2[i],
                                      LAI_SPECIES2[i],
                                      SP_HEIGHT[i]]])[0]

WALLACE_SP1[i] = rad_intercpt_wallace([[K_SPECIES1[i],
                                      LAI_SPECIES1[i],
                                      SP_HEIGHT[i]],
                                      [K_SPECIES2[i],
                                      LAI_SPECIES2[i],
                                      SP_HEIGHT[i]]]
                                      )[0]

WALLACE_SP1[i] = rad_intercpt_wallace([[K_SPECIES1[i], LAI_SPECIES1[i],
                                      SP_HEIGHT[i]], [K_SPECIES2[i],
                                      LAI_SPECIES2[i], SP_HEIGHT[i]]])[0]

WALLACE_SP1[i] = rad_intercpt_wallace([[K_SPECIES1[i],
                                      LAI_SPECIES1[i],
                                      SP_HEIGHT[i]],
                                      [K_SPECIES2[i],
                                      LAI_SPECIES2[i],
                                      SP_HEIGHT[i]]])[0]

Comments

0

All (except for the second/last version by Robᵩ) above solutions seem unreadable to me. This on the other hand is readable:

def rad_intercpt_wallace(arg):
    print arg

WALLACE_SP1[i] = rad_intercpt_wallace([
    [
        K_SPECIES1[i],
        LAI_SPECIES1[i],
        SP_HEIGHT[i]
    ],
    [
        K_SPECIES2[i],
        LAI_SPECIES2[i],
        SP_HEIGHT[i],
    ],
])[0]

And it seems pep8 gives no warning. And pylint complaines only about:

No config file found, using default configuration
************* Module sample3
C:  1, 0: Missing module docstring (missing-docstring)
C:  1, 0: Missing function docstring (missing-docstring)
E:  4, 0: Undefined variable 'WALLACE_SP1' (undefined-variable)
E:  4,12: Undefined variable 'i' (undefined-variable)
E:  6, 8: Undefined variable 'K_SPECIES1' (undefined-variable)
E:  6,19: Undefined variable 'i' (undefined-variable)
E:  7, 8: Undefined variable 'LAI_SPECIES1' (undefined-variable)
E:  7,21: Undefined variable 'i' (undefined-variable)
E:  8, 8: Undefined variable 'SP_HEIGHT' (undefined-variable)
E:  8,18: Undefined variable 'i' (undefined-variable)
E: 11, 8: Undefined variable 'K_SPECIES2' (undefined-variable)
E: 11,19: Undefined variable 'i' (undefined-variable)
E: 12, 8: Undefined variable 'LAI_SPECIES2' (undefined-variable)
E: 12,21: Undefined variable 'i' (undefined-variable)
E: 13, 8: Undefined variable 'SP_HEIGHT' (undefined-variable)
E: 13,18: Undefined variable 'i' (undefined-variable)

And doesn't require incredibly long lines even if function name is long.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.