diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2012-06-13 19:49:48 +0200 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2012-06-13 19:49:48 +0200 |
commit | 387addf72337cbbcce2ebc41c35896f53a83499b (patch) | |
tree | afe6c5c4d1c0bf527a367fb0459e01e120aa91c2 | |
parent | 845b5196981660b9290b5b249ccead4dbe2782db (diff) | |
download | pep8-387addf72337cbbcce2ebc41c35896f53a83499b.tar.gz |
Fix confusions between E123 and E124.
-rwxr-xr-x | pep8.py | 19 | ||||
-rw-r--r-- | testsuite/E12.py | 37 | ||||
-rw-r--r-- | testsuite/E12not.py | 16 |
3 files changed, 48 insertions, 24 deletions
@@ -452,7 +452,7 @@ def continuation_line_indentation(logical_line, tokens, indent_level, verbose): Okay: a = (\n 42) E121: a = (\n 42) E122: a = (\n42) - E123: a = (42\n ) + E123: a = (\n 42\n ) E124: a = (24,\n 42\n) E125: if (a or\n b):\n pass E126: a = (\n 42) @@ -528,13 +528,13 @@ def continuation_line_indentation(logical_line, tokens, indent_level, verbose): pass elif token_type == tokenize.OP and text in ']})': # This line starts with a closing bracket - if hang == 0: + if indent[depth]: if hasattr(indent[depth], 'add'): indent[depth] = min(indent[depth] or [0]) - if start[1] < indent[depth] - 4: + if start[1] != indent[depth]: yield (start, 'E124 closing bracket ' - 'missing visual indentation') - elif hang == 4 or not is_visual: + 'does not match visual indentation') + elif hang: 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: @@ -552,7 +552,6 @@ def continuation_line_indentation(logical_line, tokens, indent_level, verbose): if start[1] < indent[depth]: yield (start, 'E128 continuation line ' 'under-indented for visual indent') - elif is_not_hanging: yield (start, 'E127 continuation line over-' 'indented for visual indent') @@ -560,7 +559,6 @@ def continuation_line_indentation(logical_line, tokens, indent_level, verbose): # hanging indent. if hasattr(indent[depth], 'add'): indent[depth] = None - if hang <= 0: yield (start, 'E122 continuation line ' 'missing indentation or outdented') @@ -572,11 +570,8 @@ def continuation_line_indentation(logical_line, tokens, indent_level, verbose): 'for hanging indent') # parent indents should not be more than this one - indent[depth] = start[1] - d = depth - 1 - while d >= 0 and hasattr(indent[d], 'add'): - indent[d] = set([i for i in indent[d] if i <= start[1]]) - d -= 1 + for d1 in range(d + 1, depth): + indent[d1] = set([i for i in indent[d1] if i <= start[1]]) indent_any = [] diff --git a/testsuite/E12.py b/testsuite/E12.py index 066f44a..6502346 100644 --- a/testsuite/E12.py +++ b/testsuite/E12.py @@ -4,8 +4,8 @@ print "E121", ( #: E122 print "E122", ( "dent") -#: E123 -print "E123", ("visual", +#: E124 +print "E124", ("visual", "indent_two" ) #: E124 @@ -101,18 +101,18 @@ rv.update(dict.fromkeys(( 'reasonComment_de', 'reasonComment_it'), '?'), "foo") -#: E126 E124 +#: E126 eat_a_dict_a_day({ "foo": "bar", }) -#: E126 E124 +#: E126 if ( x == ( 3 ) or y == 4): pass -#: E126 E124 +#: E126 if ( x == ( 3 @@ -142,19 +142,19 @@ def qualify_by_address(self, cr, uid, ids, context=None, #: -#: E127 +#: E121 print "hello", ( "there", # "john", "dude") -#: E127 +#: E126 troublesome_hash = { "hash": "value", "long": "the quick brown fox jumps over the lazy dog before doing a " "somersault", } -#: E127 +#: E126 # probably not easily fixed, without using 'ast' troublesome_hash_ii = { "long key that tends to happen more when you're indented": @@ -199,8 +199,27 @@ foo(1, 2, 3, #: E127 foo(1, 2, 3, 4, 5, 6) -#: E123 +#: E124 d = dict('foo', help="exclude files or directories which match these " "comma separated patterns (default: %s)" % DEFAULT_EXCLUDE ) +#: E124 E128 +if line_removed: + self.event(cr, uid, + name="Removing the option for contract", + description="contract line has been removed", + ) +#: E128 +if line_removed: + self.event(cr, uid, + name="Removing the option for contract", + description="contract line has been removed", + ) +#: E124 E127 +if line_removed: + self.event(cr, uid, + name="Removing the option for contract", + description="contract line has been removed", + ) +#: diff --git a/testsuite/E12not.py b/testsuite/E12not.py index 9ce7008..21361a0 100644 --- a/testsuite/E12not.py +++ b/testsuite/E12not.py @@ -114,6 +114,9 @@ a = 3 + \ 4 + \ 5 + 6 +foo(1, 2, 3, + 4, 5, 6) + def long_function_name( var_one, var_two, var_three, @@ -457,10 +460,16 @@ troublefree_hash = { ("long key that tends to happen more " "when you're indented"): "stringwithalongtoken you don't want to break", } +# confusing but accepted... don't do that +troublesome_hash = { + "hash": "value", + "long": "the quick brown fox jumps over the lazy dog before doing a " + "somersault", + "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) -#: Okay +# d = dict('foo', help="exclude files or directories which match these " "comma separated patterns (default: %s)" % @@ -472,3 +481,4 @@ d = dict('foo', foobar="this clearly should work, because it is at " "the right indent level", ) +# |