PEP8 E128: Can't figure out why the line is tagged
I am using Sublime + Anaconda which has PyLint built in.
I can't figure out why the line pars_f_name)
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]
marked 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 marking this line as a PEP8 E128 warning.
What am I doing wrong here?
source to share
You need to defer arguments further str.format()
:
print (" WARNING: Unknown '{}' ID found in line {}\n"
" of '{}' file.\n").format(reader[0], l + 1,
pars_f_name)
# ^^^^^^^^^^^^
As a personal choice, I would put these arguments on a single indented line:
print (" WARNING: Unknown '{}' ID found in line {}\n"
" of '{}' file.\n").format(
reader[0], l + 1, pars_f_name)
This is called a dangling indent .
source to share
Replace:
print (" WARNING: Unknown '{}' ID found in line {}\n"
" of '{}' file.\n").format(reader[0], l + 1,
pars_f_name)
from:
print(
" WARNING: Unknown '{}' ID found in line {}\n"
" of '{}' file.\n".format(
reader[0], l + 1, pars_f_name
)
)
He mainly complains about the lack of indentation for the part str.format()
; but formatting your code according to the above example makes it more readable!
Update: This is called "hanging indent" in PEP8 (see @MartijnPieters answer). This answer is more like "here's how to fix it and make it readable at the same time." (unfortunately there are a lot of competing subjective opinions on this!)
source to share