Search code examples
pythonflake8

E128 continuation line under-indented for visual indent and E122 continuation line missing indentation or outdented in flake8


I have a python script and flake8 detected some errors for my script:

231 flake8  
E128 continuation line under-indented for visual indent

232 flake8  
E128 continuation line under-indented for visual indent

234 flake8  
E128 continuation line under-indented for visual indent

235 flake8  
E122 continuation line missing indentation or outdented

236 flake8  
E122 continuation line missing indentation or outdented

Here is my code:

t = someFunction (
        data, title=so, Rows=1,
        Widths=[1.2 * inch, 0.3 * inch,
        0.1 * inch, 0.3 * inch, 2 * inch, 3 * inch,
        5.00 * inch],
        style=[("sth1", (0, 0), (-1, -1), "CENTER"),
            ("sth2", (0, 0), (-1, -1), "CENTER"),
            ('sth3', (0, 0), (-1, -1), 0.5, colors.grey),
            ('sth4', (0, 0), (-1, 0), colors.orange),
            ('sth5', (0, 1), (0, -1), colors.orange),
        ])

I tried different permutations, and none work. Could anyone tell me how to format this function?


Solution

  • E122: When you use a continuation line for multiple arguments to a function, they should use the normal 4-column indentation.

    E128: When you spread elements of a list, dict, tuple, etc. over multiple lines, you need to align them on the left.

    t = someFunction (
        Widths=[1.2 * inch, 0.3 * inch,
                0.1 * inch, 0.3 * inch, 2 * inch, 3 * inch,
                5.00 * inch],
        style=[("sth1", (0, 0), (-1, -1), "CENTER"),
               ("sth2", (0, 0), (-1, -1), "CENTER"),
               ('sth3', (0, 0), (-1, -1), 0.5, colors.grey),
               ('sth4', (0, 0), (-1, 0), colors.orange),
               ('sth5', (0, 1), (0, -1), colors.orange)]
    )
    

    Here's the documentation:

    Continuation line missing indentation or outdented (E122)

    Continuation line under-indented for visual indent (E128)