Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PEP8 E128: can't figure out why a line is being flagged

I'm using Sublime + Anaconda which has a built-in PyLint feature.

I can't figure out why the pars_f_name) line in the following block:

            else:
                # Get parameters file name from path.
                pars_f_name = pars_f_path.split('/')[-1]
                print ("  WARNING: Unknown '{}' ID found in line {}\n"
                       "  of '{}' file.\n").format(reader[0], l + 1,
                       pars_f_name)

# Pack params in lists.
pl_params = [flag_make_plot, plot_frmt, plot_dpi]

is being flagged as:

[W] PEP 8 (E128): continuation line under-indented for visual indent

I've tried every indentation I could think of (as suggested here) but Anaconda keeps flagging that line as a PEP8 E128 warning.

What am I doing wrong here?

like image 421
Gabriel Avatar asked Jan 09 '23 09:01

Gabriel


1 Answers

You need to further indent the str.format() arguments:

print ("  WARNING: Unknown '{}' ID found in line {}\n"
       "  of '{}' file.\n").format(reader[0], l + 1,
                                   pars_f_name)
#                                  ^^^^^^^^^^^^

As a personal choice, I'd put those arguments all on one line, indented:

print ("  WARNING: Unknown '{}' ID found in line {}\n"
       "  of '{}' file.\n").format(
           reader[0], l + 1, pars_f_name)

This is called a hanging indent.

See the Indentation section of PEP 8; these considerations apply recursively to each nested call expression.

like image 140
Martijn Pieters Avatar answered Jan 14 '23 12:01

Martijn Pieters