@@ -497,7 +497,7 @@ def indentation(logical_line, previous_logical, indent_char,
497497
498498@register_check
499499def continued_indentation (logical_line , tokens , indent_level , hang_closing ,
500- indent_char , noqa , verbose ):
500+ indent_char , noqa , verbose , no_visual ):
501501 r"""Continuation lines indentation.
502502
503503 Continuation lines should align wrapped elements either vertically
@@ -595,7 +595,7 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
595595 # closing bracket matches indentation of opening bracket's line
596596 if hang_closing :
597597 yield start , "E133 closing bracket is missing indentation"
598- elif indent [depth ] and start [1 ] < indent [depth ]:
598+ elif indent [depth ] and start [1 ] < indent [depth ] and not no_visual :
599599 if visual_indent is not True :
600600 # visual indent is broken
601601 yield (start , "E128 continuation line "
@@ -606,7 +606,7 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
606606 yield (start , "E123 closing bracket does not match "
607607 "indentation of opening bracket's line" )
608608 hangs [depth ] = hang
609- elif visual_indent is True :
609+ elif visual_indent is True and not no_visual :
610610 # visual indent is verified
611611 indent [depth ] = start [1 ]
612612 elif visual_indent in (text , str ):
@@ -616,7 +616,7 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
616616 # indent is broken
617617 if hang <= 0 :
618618 error = "E122" , "missing indentation or outdented"
619- elif indent [depth ]:
619+ elif indent [depth ] and not no_visual :
620620 error = "E127" , "over-indented for visual indent"
621621 elif not close_bracket and hangs [depth ]:
622622 error = "E131" , "unaligned for hanging indent"
@@ -1561,6 +1561,7 @@ def __init__(self, filename=None, lines=None,
15611561 self .max_line_length = options .max_line_length
15621562 self .multiline = False # in a multiline string?
15631563 self .hang_closing = options .hang_closing
1564+ self .no_visual = options .no_visual
15641565 self .verbose = options .verbose
15651566 self .filename = filename
15661567 # Dictionary where a checker can store its custom state.
@@ -2124,7 +2125,7 @@ def get_parser(prog='pycodestyle', version=__version__):
21242125 usage = "%prog [options] input ..." )
21252126 parser .config_options = [
21262127 'exclude' , 'filename' , 'select' , 'ignore' , 'max-line-length' ,
2127- 'hang-closing' , 'count' , 'format' , 'quiet' , 'show-pep8' ,
2128+ 'hang-closing' , 'no-visual' , ' count' , 'format' , 'quiet' , 'show-pep8' ,
21282129 'show-source' , 'statistics' , 'verbose' ]
21292130 parser .add_option ('-v' , '--verbose' , default = 0 , action = 'count' ,
21302131 help = "print status messages, or debug with -vv" )
@@ -2164,6 +2165,8 @@ def get_parser(prog='pycodestyle', version=__version__):
21642165 parser .add_option ('--hang-closing' , action = 'store_true' ,
21652166 help = "hang closing bracket instead of matching "
21662167 "indentation of opening bracket's line" )
2168+ parser .add_option ('--no-visual' , action = 'store_true' ,
2169+ help = "force hanging indentation" )
21672170 parser .add_option ('--format' , metavar = 'format' , default = 'default' ,
21682171 help = "set the error format [default|pylint|<custom>]" )
21692172 parser .add_option ('--diff' , action = 'store_true' ,
0 commit comments