@@ -443,7 +443,7 @@ def indentation(logical_line, previous_logical, indent_char,
443443
444444
445445def continued_indentation (logical_line , tokens , indent_level , hang_closing ,
446- indent_char , noqa , verbose ):
446+ indent_char , noqa , verbose , no_visual ):
447447 r"""Continuation lines indentation.
448448
449449 Continuation lines should align wrapped elements either vertically
@@ -541,7 +541,7 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
541541 # closing bracket matches indentation of opening bracket's line
542542 if hang_closing :
543543 yield start , "E133 closing bracket is missing indentation"
544- elif indent [depth ] and start [1 ] < indent [depth ]:
544+ elif indent [depth ] and start [1 ] < indent [depth ] and not no_visual :
545545 if visual_indent is not True :
546546 # visual indent is broken
547547 yield (start , "E128 continuation line "
@@ -552,7 +552,7 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
552552 yield (start , "E123 closing bracket does not match "
553553 "indentation of opening bracket's line" )
554554 hangs [depth ] = hang
555- elif visual_indent is True :
555+ elif visual_indent is True and not no_visual :
556556 # visual indent is verified
557557 indent [depth ] = start [1 ]
558558 elif visual_indent in (text , str ):
@@ -562,7 +562,7 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
562562 # indent is broken
563563 if hang <= 0 :
564564 error = "E122" , "missing indentation or outdented"
565- elif indent [depth ]:
565+ elif indent [depth ] and not no_visual :
566566 error = "E127" , "over-indented for visual indent"
567567 elif not close_bracket and hangs [depth ]:
568568 error = "E131" , "unaligned for hanging indent"
@@ -1531,6 +1531,7 @@ def __init__(self, filename=None, lines=None,
15311531 self .max_line_length = options .max_line_length
15321532 self .multiline = False # in a multiline string?
15331533 self .hang_closing = options .hang_closing
1534+ self .no_visual = options .no_visual
15341535 self .verbose = options .verbose
15351536 self .filename = filename
15361537 # Dictionary where a checker can store its custom state.
@@ -2093,7 +2094,7 @@ def get_parser(prog='pycodestyle', version=__version__):
20932094 usage = "%prog [options] input ..." )
20942095 parser .config_options = [
20952096 'exclude' , 'filename' , 'select' , 'ignore' , 'max-line-length' ,
2096- 'hang-closing' , 'count' , 'format' , 'quiet' , 'show-pep8' ,
2097+ 'hang-closing' , 'no-visual' , ' count' , 'format' , 'quiet' , 'show-pep8' ,
20972098 'show-source' , 'statistics' , 'verbose' ]
20982099 parser .add_option ('-v' , '--verbose' , default = 0 , action = 'count' ,
20992100 help = "print status messages, or debug with -vv" )
@@ -2133,6 +2134,8 @@ def get_parser(prog='pycodestyle', version=__version__):
21332134 parser .add_option ('--hang-closing' , action = 'store_true' ,
21342135 help = "hang closing bracket instead of matching "
21352136 "indentation of opening bracket's line" )
2137+ parser .add_option ('--no-visual' , action = 'store_true' ,
2138+ help = "force hanging indentation" )
21362139 parser .add_option ('--format' , metavar = 'format' , default = 'default' ,
21372140 help = "set the error format [default|pylint|<custom>]" )
21382141 parser .add_option ('--diff' , action = 'store_true' ,
0 commit comments