Skip to content

Commit 9e8fdd0

Browse files
committed
Fix a false E128 for indentation with tabs and add tests; issue #155
1 parent 034b9f4 commit 9e8fdd0

4 files changed

Lines changed: 105 additions & 2 deletions

File tree

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Changelog
1111
* Change the message for E226 to make clear that it is about arithmetic
1212
operators.
1313

14+
* Fix a false positive E128 for continuation line indentation with tabs.
15+
1416
* Fix regression with the ``--diff`` option. (Issue #169)
1517

1618
* Fix the ``TestReport`` class to print the unexpected warnings and

pep8.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,9 @@ def continuation_line_indentation(logical_line, tokens, indent_level, verbose):
426426
# relative indents of physical lines
427427
rel_indent = [0] * nrows
428428
# visual indents
429-
indent = [indent_level]
430429
indent_chances = {}
431430
last_indent = tokens[0][2]
431+
indent = [last_indent[1]]
432432
if verbose >= 3:
433433
print(">>> " + tokens[0][4].rstrip())
434434

testsuite/E90.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
pass
99
except:
1010
print 'Whoops'
11-
#: E122 E128 E225 E251 E701
11+
#: E122 E225 E251 E701
1212

1313
# Do not crash if code is invalid
1414
if msg:

testsuite/W19.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,104 @@
11
#: W191
22
if False:
33
print # indented with 1 tab
4+
#:
5+
6+
7+
#: E126 W191
8+
y = x == 2 \
9+
or x == 3
10+
#: E101 W191
11+
if (
12+
x == (
13+
3
14+
) or
15+
y == 4):
16+
pass
17+
#: E101 W191
18+
if x == 2 \
19+
or y > 1 \
20+
or x == 3:
21+
pass
22+
#: E101 W191
23+
if x == 2 \
24+
or y > 1 \
25+
or x == 3:
26+
pass
27+
#:
28+
29+
#: E101 W191
30+
if (foo == bar and
31+
baz == frop):
32+
pass
33+
#: E101 W191
34+
if (
35+
foo == bar and
36+
baz == frop
37+
):
38+
pass
39+
#:
40+
41+
#: E101 W191
42+
if start[1] > end_col and not (
43+
over_indent == 4 and indent_next):
44+
return(0, "E121 continuation line over-"
45+
"indented for visual indent")
46+
#:
47+
48+
#: E101 W191
49+
50+
51+
def long_function_name(
52+
var_one, var_two, var_three,
53+
var_four):
54+
print(var_one)
55+
#: E101 W191
56+
if ((row < 0 or self.moduleCount <= row or
57+
col < 0 or self.moduleCount <= col)):
58+
raise Exception("%s,%s - %s" % (row, col, self.moduleCount))
59+
#: E101 W191
60+
if bar:
61+
return(
62+
start, 'E121 lines starting with a '
63+
'closing bracket should be indented '
64+
"to match that of the opening "
65+
"bracket's line"
66+
)
67+
#
68+
#: E101 W191
69+
# you want vertical alignment, so use a parens
70+
if ((foo.bar("baz") and
71+
foo.bar("frop")
72+
)):
73+
print "yes"
74+
#: E101 W191
75+
# also ok, but starting to look like LISP
76+
if ((foo.bar("baz") and
77+
foo.bar("frop"))):
78+
print "yes"
79+
#: E101 W191
80+
if (a == 2 or
81+
b == "abc def ghi"
82+
"jkl mno"):
83+
return True
84+
#: E101 W191
85+
if (a == 2 or
86+
b == """abc def ghi
87+
jkl mno"""):
88+
return True
89+
#: E101 W191
90+
if length > options.max_line_length:
91+
return options.max_line_length, \
92+
"E501 line too long (%d characters)" % length
93+
94+
95+
#
96+
#: E101 W191
97+
if os.path.exists(os.path.join(path, PEP8_BIN)):
98+
cmd = ([os.path.join(path, PEP8_BIN)] +
99+
self._pep8_options(targetfile))
100+
#: E101 W191
101+
if foo is None and bar is "frop" and \
102+
blah == 'yeah':
103+
blah = 'yeahnah'
104+
#:

0 commit comments

Comments
 (0)