Skip to content

Commit 7b9449d

Browse files
committed
Replace codes E111/2/3 with E114/5/6 for indentation of comments; issue #274
1 parent a176b77 commit 7b9449d

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Bug fixes:
99

1010
* Skip the traceback on "Broken pipe" signal. (Issue #275)
1111

12+
* Replace codes E111, E112 and E113 with codes E114, E115 and E116
13+
for wrong indentation of comments. (Issue #274)
14+
1215

1316
1.5.6 (2014-04-14)
1417
------------------

docs/intro.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ This is the current list of error and warning codes:
193193
+----------+----------------------------------------------------------------------+
194194
| E113 | unexpected indentation |
195195
+----------+----------------------------------------------------------------------+
196+
| E114 | indentation is not a multiple of four (comment) |
197+
+----------+----------------------------------------------------------------------+
198+
| E115 | expected an indented block (comment) |
199+
+----------+----------------------------------------------------------------------+
200+
| E116 | unexpected indentation (comment) |
201+
+----------+----------------------------------------------------------------------+
196202
+----------+----------------------------------------------------------------------+
197203
| E121 (^) | continuation line under-indented for hanging indent |
198204
+----------+----------------------------------------------------------------------+

pep8.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,20 +353,25 @@ def indentation(logical_line, previous_logical, indent_char,
353353
Okay: a = 1
354354
Okay: if a == 0:\n a = 1
355355
E111: a = 1
356+
E114: # a = 1
356357
357358
Okay: for item in items:\n pass
358359
E112: for item in items:\npass
360+
E115: for item in items:\n# Hi\n pass
359361
360362
Okay: a = 1\nb = 2
361363
E113: a = 1\n b = 2
364+
E116: a = 1\n # b = 2
362365
"""
363-
if indent_char == ' ' and indent_level % 4:
364-
yield 0, "E111 indentation is not a multiple of four"
366+
c = 0 if logical_line else 3
367+
tmpl = "E11%d %s" if logical_line else "E11%d %s (comment)"
368+
if indent_level % 4:
369+
yield 0, tmpl % (1 + c, "indentation is not a multiple of four")
365370
indent_expect = previous_logical.endswith(':')
366371
if indent_expect and indent_level <= previous_indent_level:
367-
yield 0, "E112 expected an indented block"
368-
if indent_level > previous_indent_level and not indent_expect:
369-
yield 0, "E113 unexpected indentation"
372+
yield 0, tmpl % (2 + c, "expected an indented block")
373+
elif not indent_expect and indent_level > previous_indent_level:
374+
yield 0, tmpl % (3 + c, "unexpected indentation")
370375

371376

372377
def continued_indentation(logical_line, tokens, indent_level, hang_closing,

testsuite/E11.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,27 @@
1010
#: E113
1111
print
1212
print
13-
#: E111 E113
13+
#: E114 E116
1414
mimetype = 'application/x-directory'
1515
# 'httpd/unix-directory'
1616
create_date = False
17+
#: E116 E116 E116
18+
def start(self):
19+
if True:
20+
self.master.start()
21+
# try:
22+
# self.master.start()
23+
# except MasterExit:
24+
# self.shutdown()
25+
# finally:
26+
# sys.exit()
27+
#: E115 E115 E115 E115 E115 E115
28+
def start(self):
29+
if True:
30+
# try:
31+
# self.master.start()
32+
# except MasterExit:
33+
# self.shutdown()
34+
# finally:
35+
# sys.exit()
36+
self.master.start()

0 commit comments

Comments
 (0)