6363 from ConfigParser import RawConfigParser
6464
6565DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git,__pycache__'
66- DEFAULT_IGNORE = 'E226,E24'
66+ DEFAULT_IGNORE = 'E123, E226,E24'
6767if sys .platform == 'win32' :
6868 DEFAULT_CONFIG = os .path .expanduser (r'~\.pep8' )
6969else :
@@ -381,7 +381,8 @@ def indentation(logical_line, previous_logical, indent_char,
381381 yield 0 , "E113 unexpected indentation"
382382
383383
384- def continued_indentation (logical_line , tokens , indent_level , noqa , verbose ):
384+ def continued_indentation (logical_line , tokens , indent_level , hang_closing ,
385+ noqa , verbose ):
385386 r"""
386387 Continuation lines should align wrapped elements either vertically using
387388 Python's implicit line joining inside parentheses, brackets and braces, or
@@ -467,7 +468,8 @@ def continued_indentation(logical_line, tokens, indent_level, noqa, verbose):
467468 "visual indentation" )
468469 elif close_bracket and not hang :
469470 # closing bracket matches indentation of opening bracket's line
470- pass
471+ if hang_closing :
472+ yield start , "E133 closing bracket is missing indentation"
471473 elif visual_indent is True :
472474 # visual indent is verified
473475 if not indent [depth ]:
@@ -481,7 +483,7 @@ def continued_indentation(logical_line, tokens, indent_level, noqa, verbose):
481483 "under-indented for visual indent" )
482484 elif hang == 4 or (indent_next and rel_indent [row ] == 8 ):
483485 # hanging indent is verified
484- if close_bracket :
486+ if close_bracket and not hang_closing :
485487 yield (start , "E123 closing bracket does not match "
486488 "indentation of opening bracket's line" )
487489 else :
@@ -1184,6 +1186,7 @@ def __init__(self, filename=None, lines=None,
11841186 self ._logical_checks = options .logical_checks
11851187 self ._ast_checks = options .ast_checks
11861188 self .max_line_length = options .max_line_length
1189+ self .hang_closing = options .hang_closing
11871190 self .verbose = options .verbose
11881191 self .filename = filename
11891192 if filename is None :
@@ -1694,8 +1697,9 @@ def get_parser(prog='pep8', version=__version__):
16941697 parser = OptionParser (prog = prog , version = version ,
16951698 usage = "%prog [options] input ..." )
16961699 parser .config_options = [
1697- 'exclude' , 'filename' , 'select' , 'ignore' , 'max-line-length' , 'count' ,
1698- 'format' , 'quiet' , 'show-pep8' , 'show-source' , 'statistics' , 'verbose' ]
1700+ 'exclude' , 'filename' , 'select' , 'ignore' , 'max-line-length' ,
1701+ 'hang-closing' , 'count' , 'format' , 'quiet' , 'show-pep8' ,
1702+ 'show-source' , 'statistics' , 'verbose' ]
16991703 parser .add_option ('-v' , '--verbose' , default = 0 , action = 'count' ,
17001704 help = "print status messages, or debug with -vv" )
17011705 parser .add_option ('-q' , '--quiet' , default = 0 , action = 'count' ,
@@ -1730,6 +1734,9 @@ def get_parser(prog='pep8', version=__version__):
17301734 default = MAX_LINE_LENGTH ,
17311735 help = "set maximum allowed line length "
17321736 "(default: %default)" )
1737+ parser .add_option ('--hang-closing' , action = 'store_true' ,
1738+ help = "hang closing bracket instead of matching "
1739+ "indentation of opening bracket's line" )
17331740 parser .add_option ('--format' , metavar = 'format' , default = 'default' ,
17341741 help = "set the error format [default|pylint|<custom>]" )
17351742 parser .add_option ('--diff' , action = 'store_true' ,
0 commit comments