Skip to content

Commit 2a1117c

Browse files
committed
Clarify E121 and E126 for hanging indents, and reports all over-indented continuation lines under E126.
1 parent 2336afa commit 2a1117c

4 files changed

Lines changed: 16 additions & 9 deletions

File tree

CHANGES.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ Changelog
1313
* Report E713 and E714 when operators ``not in`` and ``is not`` are
1414
recommended. (Issue #236)
1515

16+
* Change text for E121 to report "continuation line under-indented
17+
for hanging indent" instead of indentation not being a
18+
multiple of 4.
19+
20+
* Report E126 instead of E121 when the continuation line is hanging
21+
with extra indentation, even if indentation is not a multiple of 4.
22+
1623
* Allow the checkers to report errors on empty files. (Issue #240)
1724

1825
* Fix ignoring too many checks when ``--select`` is used with codes

docs/intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ This is the current list of error and warning codes:
194194
| E113 | unexpected indentation |
195195
+----------+----------------------------------------------------------------------+
196196
+----------+----------------------------------------------------------------------+
197-
| E121 (^) | continuation line indentation is not a multiple of four |
197+
| E121 (^) | continuation line under-indented for hanging indent |
198198
+----------+----------------------------------------------------------------------+
199199
| E122 (^) | continuation line missing indentation or outdented |
200200
+----------+----------------------------------------------------------------------+

pep8.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,10 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
499499
error = "E122", "missing indentation or outdented"
500500
elif indent[depth]:
501501
error = "E127", "over-indented for visual indent"
502-
elif hang % 4:
503-
error = "E121", "indentation is not a multiple of four"
504-
else:
502+
elif hang > 4:
505503
error = "E126", "over-indented for hanging indent"
504+
else:
505+
error = "E121", "under-indented for hanging indent"
506506
yield start, "%s continuation line %s" % error
507507

508508
# look for visual indenting

testsuite/E12.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#:
4343

4444

45-
#: E121
45+
#: E126
4646
my_list = [
4747
1, 2, 3,
4848
4, 5, 6,
@@ -52,23 +52,23 @@
5252
'key1': 'value',
5353
'key2': 'value',
5454
}
55-
#: E121 E121
55+
#: E126 E126
5656
rv.update(dict.fromkeys((
5757
'qualif_nr', 'reasonComment_en', 'reasonComment_fr',
5858
'reasonComment_de', 'reasonComment_it'),
5959
'?'),
6060
"foo")
61-
#: E121 E121
61+
#: E126 E126
6262
abricot = 3 + \
6363
4 + \
6464
5 + 6
65-
#: E121
65+
#: E126
6666
print "hello", (
6767

6868
"there",
6969
# "john",
7070
"dude")
71-
#: E121
71+
#: E126
7272
part = set_mimetype((
7373
a.get('mime_type', 'text')),
7474
'default')

0 commit comments

Comments
 (0)