@@ -443,7 +443,7 @@ def indentation(logical_line, previous_logical, indent_char,
443
443
444
444
445
445
def continued_indentation (logical_line , tokens , indent_level , hang_closing ,
446
- indent_char , noqa , verbose ):
446
+ indent_char , noqa , verbose , no_visual ):
447
447
r"""Continuation lines indentation.
448
448
449
449
Continuation lines should align wrapped elements either vertically
@@ -541,7 +541,7 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
541
541
# closing bracket matches indentation of opening bracket's line
542
542
if hang_closing :
543
543
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 :
545
545
if visual_indent is not True :
546
546
# visual indent is broken
547
547
yield (start , "E128 continuation line "
@@ -552,7 +552,7 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
552
552
yield (start , "E123 closing bracket does not match "
553
553
"indentation of opening bracket's line" )
554
554
hangs [depth ] = hang
555
- elif visual_indent is True :
555
+ elif visual_indent is True and not no_visual :
556
556
# visual indent is verified
557
557
indent [depth ] = start [1 ]
558
558
elif visual_indent in (text , str ):
@@ -562,7 +562,7 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
562
562
# indent is broken
563
563
if hang <= 0 :
564
564
error = "E122" , "missing indentation or outdented"
565
- elif indent [depth ]:
565
+ elif indent [depth ] and not no_visual :
566
566
error = "E127" , "over-indented for visual indent"
567
567
elif not close_bracket and hangs [depth ]:
568
568
error = "E131" , "unaligned for hanging indent"
@@ -1531,6 +1531,7 @@ def __init__(self, filename=None, lines=None,
1531
1531
self .max_line_length = options .max_line_length
1532
1532
self .multiline = False # in a multiline string?
1533
1533
self .hang_closing = options .hang_closing
1534
+ self .no_visual = options .no_visual
1534
1535
self .verbose = options .verbose
1535
1536
self .filename = filename
1536
1537
# Dictionary where a checker can store its custom state.
@@ -2093,7 +2094,7 @@ def get_parser(prog='pycodestyle', version=__version__):
2093
2094
usage = "%prog [options] input ..." )
2094
2095
parser .config_options = [
2095
2096
'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' ,
2097
2098
'show-source' , 'statistics' , 'verbose' ]
2098
2099
parser .add_option ('-v' , '--verbose' , default = 0 , action = 'count' ,
2099
2100
help = "print status messages, or debug with -vv" )
@@ -2133,6 +2134,8 @@ def get_parser(prog='pycodestyle', version=__version__):
2133
2134
parser .add_option ('--hang-closing' , action = 'store_true' ,
2134
2135
help = "hang closing bracket instead of matching "
2135
2136
"indentation of opening bracket's line" )
2137
+ parser .add_option ('--no-visual' , action = 'store_true' ,
2138
+ help = "force hanging indentation" )
2136
2139
parser .add_option ('--format' , metavar = 'format' , default = 'default' ,
2137
2140
help = "set the error format [default|pylint|<custom>]" )
2138
2141
parser .add_option ('--diff' , action = 'store_true' ,
0 commit comments