@@ -497,7 +497,7 @@ def indentation(logical_line, previous_logical, indent_char,
497
497
498
498
@register_check
499
499
def continued_indentation (logical_line , tokens , indent_level , hang_closing ,
500
- indent_char , noqa , verbose ):
500
+ indent_char , noqa , verbose , no_visual ):
501
501
r"""Continuation lines indentation.
502
502
503
503
Continuation lines should align wrapped elements either vertically
@@ -595,7 +595,7 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
595
595
# closing bracket matches indentation of opening bracket's line
596
596
if hang_closing :
597
597
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 :
599
599
if visual_indent is not True :
600
600
# visual indent is broken
601
601
yield (start , "E128 continuation line "
@@ -606,7 +606,7 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
606
606
yield (start , "E123 closing bracket does not match "
607
607
"indentation of opening bracket's line" )
608
608
hangs [depth ] = hang
609
- elif visual_indent is True :
609
+ elif visual_indent is True and not no_visual :
610
610
# visual indent is verified
611
611
indent [depth ] = start [1 ]
612
612
elif visual_indent in (text , str ):
@@ -616,7 +616,7 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
616
616
# indent is broken
617
617
if hang <= 0 :
618
618
error = "E122" , "missing indentation or outdented"
619
- elif indent [depth ]:
619
+ elif indent [depth ] and not no_visual :
620
620
error = "E127" , "over-indented for visual indent"
621
621
elif not close_bracket and hangs [depth ]:
622
622
error = "E131" , "unaligned for hanging indent"
@@ -1561,6 +1561,7 @@ def __init__(self, filename=None, lines=None,
1561
1561
self .max_line_length = options .max_line_length
1562
1562
self .multiline = False # in a multiline string?
1563
1563
self .hang_closing = options .hang_closing
1564
+ self .no_visual = options .no_visual
1564
1565
self .verbose = options .verbose
1565
1566
self .filename = filename
1566
1567
# Dictionary where a checker can store its custom state.
@@ -2124,7 +2125,7 @@ def get_parser(prog='pycodestyle', version=__version__):
2124
2125
usage = "%prog [options] input ..." )
2125
2126
parser .config_options = [
2126
2127
'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' ,
2128
2129
'show-source' , 'statistics' , 'verbose' ]
2129
2130
parser .add_option ('-v' , '--verbose' , default = 0 , action = 'count' ,
2130
2131
help = "print status messages, or debug with -vv" )
@@ -2164,6 +2165,8 @@ def get_parser(prog='pycodestyle', version=__version__):
2164
2165
parser .add_option ('--hang-closing' , action = 'store_true' ,
2165
2166
help = "hang closing bracket instead of matching "
2166
2167
"indentation of opening bracket's line" )
2168
+ parser .add_option ('--no-visual' , action = 'store_true' ,
2169
+ help = "force hanging indentation" )
2167
2170
parser .add_option ('--format' , metavar = 'format' , default = 'default' ,
2168
2171
help = "set the error format [default|pylint|<custom>]" )
2169
2172
parser .add_option ('--diff' , action = 'store_true' ,
0 commit comments