Skip to content

Commit 9de61e1

Browse files
committed
Report other E12 errors when E123 is ignored; issue #103
1 parent 3745d79 commit 9de61e1

4 files changed

Lines changed: 73 additions & 12 deletions

File tree

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Changelog
1515

1616
* Compare full path when exluding a file. (Issue #186)
1717

18+
* Correctly report other E12 errors when E123 is ignored. (Issue #103)
19+
1820

1921
1.4.5 (2013-03-06)
2022
------------------

pep8.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -457,17 +457,17 @@ def continued_indentation(logical_line, tokens, indent_level, noqa, verbose):
457457
# an unbracketed continuation line (ie, backslash)
458458
open_row = 0
459459
hang = rel_indent[row] - rel_indent[open_row]
460-
visual_indent = indent_chances.get(start[1])
461-
462-
if token_type == tokenize.OP and text in ']})':
463-
# this line starts with a closing bracket
464-
if indent[depth]:
465-
if start[1] != indent[depth]:
466-
yield (start, "E124 closing bracket does not match "
467-
"visual indentation")
468-
elif hang:
469-
yield (start, "E123 closing bracket does not match "
470-
"indentation of opening bracket's line")
460+
close_bracket = (token_type == tokenize.OP and text in ']})')
461+
visual_indent = not close_bracket and indent_chances.get(start[1])
462+
463+
if close_bracket and indent[depth]:
464+
# closing bracket for visual indent
465+
if start[1] != indent[depth]:
466+
yield (start, "E124 closing bracket does not match "
467+
"visual indentation")
468+
elif close_bracket and not hang:
469+
# closing bracket matches indentation of opening bracket's line
470+
pass
471471
elif visual_indent is True:
472472
# visual indent is verified
473473
if not indent[depth]:
@@ -481,7 +481,9 @@ def continued_indentation(logical_line, tokens, indent_level, noqa, verbose):
481481
"under-indented for visual indent")
482482
elif hang == 4 or (indent_next and rel_indent[row] == 8):
483483
# hanging indent is verified
484-
pass
484+
if close_bracket:
485+
yield (start, "E123 closing bracket does not match "
486+
"indentation of opening bracket's line")
485487
else:
486488
# indent is broken
487489
if hang <= 0:

testsuite/E12.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,44 @@
5050
}
5151
]
5252
}
53+
#: E123
54+
my_list = [
55+
1, 2, 3,
56+
4, 5, 6,
57+
]
58+
#: E123
59+
result = some_function_that_takes_arguments(
60+
'a', 'b', 'c',
61+
'd', 'e', 'f',
62+
)
63+
#: E124
64+
my_list = [1, 2, 3,
65+
4, 5, 6,
66+
]
67+
#: E124
68+
my_list = [1, 2, 3,
69+
4, 5, 6,
70+
]
71+
#: E124
72+
result = some_function_that_takes_arguments('a', 'b', 'c',
73+
'd', 'e', 'f',
74+
)
75+
#: E121
76+
my_list = [
77+
1, 2, 3,
78+
4, 5, 6,
79+
]
80+
#: E126
81+
my_list = [
82+
1, 2, 3,
83+
4, 5, 6,
84+
]
85+
#: E122
86+
if True:
87+
result = some_function_that_takes_arguments(
88+
'a', 'b', 'c',
89+
'd', 'e', 'f',
90+
)
5391
#: E121
5492
result = {
5593
'key1': 'value',

testsuite/E12not.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,3 +546,22 @@ def f():
546546
c > d:
547547
moo_like_a_cow()
548548
#
549+
my_list = [
550+
1, 2, 3,
551+
4, 5, 6,
552+
]
553+
554+
my_list = [1, 2, 3,
555+
4, 5, 6,
556+
]
557+
558+
result = some_function_that_takes_arguments(
559+
'a', 'b', 'c',
560+
'd', 'e', 'f',
561+
)
562+
563+
result = some_function_that_takes_arguments('a', 'b', 'c',
564+
'd', 'e', 'f',
565+
)
566+
567+
#

0 commit comments

Comments
 (0)