diff options
-rwxr-xr-x | pep8.py | 10 | ||||
-rw-r--r-- | testsuite/E12.py | 25 | ||||
-rw-r--r-- | testsuite/E12not.py | 16 |
3 files changed, 49 insertions, 2 deletions
@@ -474,6 +474,7 @@ def continuation_line_indentation(logical_line, tokens, indent_level): indent_next = logical_line.endswith(':') indent_string = None + indent_any = [] row = depth = 0 # remember how many brackets were opened on each line parens = [0] * nrows @@ -537,6 +538,9 @@ def continuation_line_indentation(logical_line, tokens, indent_level): elif hang == 4 or not is_visual: yield (start, 'E123 closing bracket does not match ' 'indentation of opening bracket\'s line') + elif token_type == tokenize.OP and (start[1], text) in indent_any: + # token lined up with matching one from a previous line, OK + pass elif is_visual: # Visual indent is verified for d1 in range(d, depth + 1): @@ -575,6 +579,8 @@ def continuation_line_indentation(logical_line, tokens, indent_level): indent[d] = set([i for i in indent[d] if i <= start[1]]) d -= 1 + indent_any = [] + # look for visual indenting if ((parens[row] and token_type != tokenize.NL and hasattr(indent[depth], 'add'))): @@ -590,6 +596,10 @@ def continuation_line_indentation(logical_line, tokens, indent_level): elif token_type == tokenize.STRING: indent_string = start[1] + # let people line up tokens, if they truly must. + if token_type == tokenize.OP: + indent_any.append((start[1], text)) + # keep track of bracket depth if token_type == tokenize.OP: if text in '([{': diff --git a/testsuite/E12.py b/testsuite/E12.py index c5e767a..f5c7c97 100644 --- a/testsuite/E12.py +++ b/testsuite/E12.py @@ -160,4 +160,27 @@ troublesome_hash_ii = { "long key that tends to happen more when you're indented": "stringwithalongtoken you don't want to break", } -#: +#: E128 +foo(1, 2, 3, +4, 5, 6) +#: E128 +foo(1, 2, 3, + 4, 5, 6) +#: E128 +foo(1, 2, 3, + 4, 5, 6) +#: E128 +foo(1, 2, 3, + 4, 5, 6) +#: E127 +foo(1, 2, 3, + 4, 5, 6) +#: E127 +foo(1, 2, 3, + 4, 5, 6) +#: E127 +foo(1, 2, 3, + 4, 5, 6) +#: E127 +foo(1, 2, 3, + 4, 5, 6) diff --git a/testsuite/E12not.py b/testsuite/E12not.py index a29b14e..4a49375 100644 --- a/testsuite/E12not.py +++ b/testsuite/E12not.py @@ -363,7 +363,6 @@ def unicode2html(s): .replace('"', '"') .replace('\n', '<br>\n')) - # parser.add_option('--count', action='store_true', help="print total number of errors and warnings " @@ -422,3 +421,18 @@ troublefree_hash = { ("long key that tends to happen more " "when you're indented"): "stringwithalongtoken you don't want to break", } + +foo(1, 2, 3, + 4, 5, 6) + +# TODO +foo(1, 2, 3, + 4, 5, 6) +foo(1, 2, 3, + 4, 5, 6) +foo(1, 2, 3, + 4, 5, 6) +foo(1, 2, 3, + 4, 5, 6) +foo(1, 2, 3, + 4, 5, 6) |