diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2014-05-29 19:27:05 +0200 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2014-05-29 19:27:05 +0200 |
commit | 3fbadb7007436c029a3ede4c057ce43171dcd617 (patch) | |
tree | 470427306dea2f04fdb228f66d25d9bb50fe0fae | |
parent | 46a2d180b43c152c3fbad91487a77c69a86bcf4d (diff) | |
parent | 8a37cd90fdc731d151628b541d3edfd056f67e7c (diff) | |
download | pep8-3fbadb7007436c029a3ede4c057ce43171dcd617.tar.gz |
Replace codes E111/2/3 with E114/5/6 for indentation of comments; issue #274
-rw-r--r-- | CHANGES.txt | 3 | ||||
-rw-r--r-- | docs/intro.rst | 6 | ||||
-rwxr-xr-x | pep8.py | 15 | ||||
-rw-r--r-- | testsuite/E11.py | 22 | ||||
-rw-r--r-- | testsuite/test_api.py | 4 | ||||
-rw-r--r-- | testsuite/test_shell.py | 2 |
6 files changed, 43 insertions, 9 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index d7c09b9..9bd0c74 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,6 +9,9 @@ Changelog * Report E704 for one-liner def instead of E701. (Issue #277) +* Replace codes E111, E112 and E113 with codes E114, E115 and E116 + for wrong indentation of comments. (Issue #274) + 1.5.7 (2014-05-29) ------------------ diff --git a/docs/intro.rst b/docs/intro.rst index 27f125a..cdff2ac 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -194,6 +194,12 @@ This is the current list of error and warning codes: +----------+----------------------------------------------------------------------+ | E113 | unexpected indentation | +----------+----------------------------------------------------------------------+ +| E114 | indentation is not a multiple of four (comment) | ++----------+----------------------------------------------------------------------+ +| E115 | expected an indented block (comment) | ++----------+----------------------------------------------------------------------+ +| E116 | unexpected indentation (comment) | ++----------+----------------------------------------------------------------------+ +----------+----------------------------------------------------------------------+ | E121 (^) | continuation line under-indented for hanging indent | +----------+----------------------------------------------------------------------+ @@ -353,20 +353,25 @@ def indentation(logical_line, previous_logical, indent_char, Okay: a = 1 Okay: if a == 0:\n a = 1 E111: a = 1 + E114: # a = 1 Okay: for item in items:\n pass E112: for item in items:\npass + E115: for item in items:\n# Hi\n pass Okay: a = 1\nb = 2 E113: a = 1\n b = 2 + E116: a = 1\n # b = 2 """ - if indent_char == ' ' and indent_level % 4: - yield 0, "E111 indentation is not a multiple of four" + c = 0 if logical_line else 3 + tmpl = "E11%d %s" if logical_line else "E11%d %s (comment)" + if indent_level % 4: + yield 0, tmpl % (1 + c, "indentation is not a multiple of four") indent_expect = previous_logical.endswith(':') if indent_expect and indent_level <= previous_indent_level: - yield 0, "E112 expected an indented block" - if indent_level > previous_indent_level and not indent_expect: - yield 0, "E113 unexpected indentation" + yield 0, tmpl % (2 + c, "expected an indented block") + elif not indent_expect and indent_level > previous_indent_level: + yield 0, tmpl % (3 + c, "unexpected indentation") def continued_indentation(logical_line, tokens, indent_level, hang_closing, diff --git a/testsuite/E11.py b/testsuite/E11.py index 98b9431..4ed1096 100644 --- a/testsuite/E11.py +++ b/testsuite/E11.py @@ -10,7 +10,27 @@ print #: E113 print print -#: E111 E113 +#: E114 E116 mimetype = 'application/x-directory' # 'httpd/unix-directory' create_date = False +#: E116 E116 E116 +def start(self): + if True: + self.master.start() + # try: + # self.master.start() + # except MasterExit: + # self.shutdown() + # finally: + # sys.exit() +#: E115 E115 E115 E115 E115 E115 +def start(self): + if True: +# try: +# self.master.start() +# except MasterExit: +# self.shutdown() +# finally: +# sys.exit() + self.master.start() diff --git a/testsuite/test_api.py b/testsuite/test_api.py index fba27c7..980fe9e 100644 --- a/testsuite/test_api.py +++ b/testsuite/test_api.py @@ -124,7 +124,7 @@ class APITestCase(unittest.TestCase): report = pep8.StyleGuide().check_files([E11]) stdout = sys.stdout.getvalue().splitlines() self.assertEqual(len(stdout), report.total_errors) - self.assertEqual(report.total_errors, 6) + self.assertEqual(report.total_errors, 17) self.assertFalse(sys.stderr) self.reset() @@ -132,7 +132,7 @@ class APITestCase(unittest.TestCase): report = pep8.StyleGuide(paths=[E11]).check_files() stdout = sys.stdout.getvalue().splitlines() self.assertEqual(len(stdout), report.total_errors) - self.assertEqual(report.total_errors, 6) + self.assertEqual(report.total_errors, 17) self.assertFalse(sys.stderr) self.reset() diff --git a/testsuite/test_shell.py b/testsuite/test_shell.py index e1205cc..e536852 100644 --- a/testsuite/test_shell.py +++ b/testsuite/test_shell.py @@ -75,7 +75,7 @@ class ShellTestCase(unittest.TestCase): stdout = stdout.splitlines() self.assertEqual(errcode, 1) self.assertFalse(stderr) - self.assertEqual(len(stdout), 6) + self.assertEqual(len(stdout), 17) for line, num, col in zip(stdout, (3, 6, 9, 12), (3, 6, 1, 5)): path, x, y, msg = line.split(':') self.assertTrue(path.endswith(E11)) |