diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2014-03-25 02:45:40 +0100 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2014-03-25 02:45:40 +0100 |
commit | 2a1117c9988532942b81bb60639038e9c9e6bdaa (patch) | |
tree | 4bd1939b720bb7ff3a467ea3936d0b2872a1c05c | |
parent | 2336afaf09875f1501f0fb05dc11c477c5c77bc1 (diff) | |
download | pep8-2a1117c9988532942b81bb60639038e9c9e6bdaa.tar.gz |
Clarify E121 and E126 for hanging indents, and reports all over-indented continuation lines under E126.
-rw-r--r-- | CHANGES.txt | 7 | ||||
-rw-r--r-- | docs/intro.rst | 2 | ||||
-rwxr-xr-x | pep8.py | 6 | ||||
-rw-r--r-- | testsuite/E12.py | 10 |
4 files changed, 16 insertions, 9 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index c2ff646..a0ef923 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -13,6 +13,13 @@ Changelog * Report E713 and E714 when operators ``not in`` and ``is not`` are recommended. (Issue #236) +* Change text for E121 to report "continuation line under-indented + for hanging indent" instead of indentation not being a + multiple of 4. + +* Report E126 instead of E121 when the continuation line is hanging + with extra indentation, even if indentation is not a multiple of 4. + * Allow the checkers to report errors on empty files. (Issue #240) * Fix ignoring too many checks when ``--select`` is used with codes diff --git a/docs/intro.rst b/docs/intro.rst index 7d2f16d..d88b792 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -194,7 +194,7 @@ This is the current list of error and warning codes: | E113 | unexpected indentation | +----------+----------------------------------------------------------------------+ +----------+----------------------------------------------------------------------+ -| E121 (^) | continuation line indentation is not a multiple of four | +| E121 (^) | continuation line under-indented for hanging indent | +----------+----------------------------------------------------------------------+ | E122 (^) | continuation line missing indentation or outdented | +----------+----------------------------------------------------------------------+ @@ -499,10 +499,10 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing, error = "E122", "missing indentation or outdented" elif indent[depth]: error = "E127", "over-indented for visual indent" - elif hang % 4: - error = "E121", "indentation is not a multiple of four" - else: + elif hang > 4: error = "E126", "over-indented for hanging indent" + else: + error = "E121", "under-indented for hanging indent" yield start, "%s continuation line %s" % error # look for visual indenting diff --git a/testsuite/E12.py b/testsuite/E12.py index 1328091..ed12232 100644 --- a/testsuite/E12.py +++ b/testsuite/E12.py @@ -42,7 +42,7 @@ print "E128", ("under-", #: -#: E121 +#: E126 my_list = [ 1, 2, 3, 4, 5, 6, @@ -52,23 +52,23 @@ result = { 'key1': 'value', 'key2': 'value', } -#: E121 E121 +#: E126 E126 rv.update(dict.fromkeys(( 'qualif_nr', 'reasonComment_en', 'reasonComment_fr', 'reasonComment_de', 'reasonComment_it'), '?'), "foo") -#: E121 E121 +#: E126 E126 abricot = 3 + \ 4 + \ 5 + 6 -#: E121 +#: E126 print "hello", ( "there", # "john", "dude") -#: E121 +#: E126 part = set_mimetype(( a.get('mime_type', 'text')), 'default') |