Svelvet
Svelvet copied to clipboard
E226: pycodestyle incorrectly warns about missing whitespace around operators
Given the following example.py
,
my_list = [1, 2, 3]
a = 2+2
b = my_list[1:1+1]
pycodestyle
incorrectly warns about the missing whitespace for the +
operator inside the list slice:
» pycodestyle --select E226 ./example.py
./example.py:2:6: E226 missing whitespace around arithmetic operator # OK
./example.py:3:16: E226 missing whitespace around arithmetic operator # incorrect
The first warning (line 2) is correct (line 2 should read a = 2 + 2
); the second warning (line 3) is incorrect according to PEP-8:
Yes:
ham[1:9], ham[1:9:3], ham[:9:3], ham[1::3], ham[1:9:] ham[lower:upper], ham[lower:upper:], ham[lower::step] ham[lower+offset : upper+offset] ham[: upper_fn(x) : step_fn(x)], ham[:: step_fn(x)] ham[lower + offset : upper + offset]
No:
ham[lower + offset:upper + offset] ham[1: 9], ham[1 :9], ham[1:9 :3] ham[lower : : upper] ham[ : upper]
Edit: okay, I'm not so sure I've got it 100%. The style I think is PEP-8 doesn't really seem to get listed anywhere, but even if I add spaces around the :
(which is listed), I still get lints.