4545700 statements
4646900 syntax error
4747"""
48- __version__ = '1.4.6a0 '
48+ __version__ = '1.4.6 '
4949
5050import os
5151import sys
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
@@ -458,7 +459,8 @@ def continued_indentation(logical_line, tokens, indent_level, noqa, verbose):
458459 open_row = 0
459460 hang = rel_indent [row ] - rel_indent [open_row ]
460461 close_bracket = (token_type == tokenize .OP and text in ']})' )
461- visual_indent = not close_bracket and indent_chances .get (start [1 ])
462+ visual_indent = (not close_bracket and hang > 0 and
463+ indent_chances .get (start [1 ]))
462464
463465 if close_bracket and indent [depth ]:
464466 # closing bracket for visual indent
@@ -467,7 +469,8 @@ def continued_indentation(logical_line, tokens, indent_level, noqa, verbose):
467469 "visual indentation" )
468470 elif close_bracket and not hang :
469471 # closing bracket matches indentation of opening bracket's line
470- pass
472+ if hang_closing :
473+ yield start , "E133 closing bracket is missing indentation"
471474 elif visual_indent is True :
472475 # visual indent is verified
473476 if not indent [depth ]:
@@ -481,7 +484,7 @@ def continued_indentation(logical_line, tokens, indent_level, noqa, verbose):
481484 "under-indented for visual indent" )
482485 elif hang == 4 or (indent_next and rel_indent [row ] == 8 ):
483486 # hanging indent is verified
484- if close_bracket :
487+ if close_bracket and not hang_closing :
485488 yield (start , "E123 closing bracket does not match "
486489 "indentation of opening bracket's line" )
487490 else :
@@ -535,6 +538,7 @@ def continued_indentation(logical_line, tokens, indent_level, noqa, verbose):
535538 for idx in range (row , - 1 , - 1 ):
536539 if parens [idx ]:
537540 parens [idx ] -= 1
541+ rel_indent [row ] = rel_indent [idx ]
538542 break
539543 assert len (indent ) == depth + 1
540544 if start [1 ] not in indent_chances :
@@ -543,7 +547,7 @@ def continued_indentation(logical_line, tokens, indent_level, noqa, verbose):
543547
544548 last_token_multiline = (start [0 ] != end [0 ])
545549
546- if indent_next and rel_indent [ - 1 ] == 4 :
550+ if indent_next and expand_indent ( line ) == indent_level + 4 :
547551 yield (last_indent , "E125 continuation line does not distinguish "
548552 "itself from next logical line" )
549553
@@ -1183,6 +1187,7 @@ def __init__(self, filename=None, lines=None,
11831187 self ._logical_checks = options .logical_checks
11841188 self ._ast_checks = options .ast_checks
11851189 self .max_line_length = options .max_line_length
1190+ self .hang_closing = options .hang_closing
11861191 self .verbose = options .verbose
11871192 self .filename = filename
11881193 if filename is None :
@@ -1693,8 +1698,9 @@ def get_parser(prog='pep8', version=__version__):
16931698 parser = OptionParser (prog = prog , version = version ,
16941699 usage = "%prog [options] input ..." )
16951700 parser .config_options = [
1696- 'exclude' , 'filename' , 'select' , 'ignore' , 'max-line-length' , 'count' ,
1697- 'format' , 'quiet' , 'show-pep8' , 'show-source' , 'statistics' , 'verbose' ]
1701+ 'exclude' , 'filename' , 'select' , 'ignore' , 'max-line-length' ,
1702+ 'hang-closing' , 'count' , 'format' , 'quiet' , 'show-pep8' ,
1703+ 'show-source' , 'statistics' , 'verbose' ]
16981704 parser .add_option ('-v' , '--verbose' , default = 0 , action = 'count' ,
16991705 help = "print status messages, or debug with -vv" )
17001706 parser .add_option ('-q' , '--quiet' , default = 0 , action = 'count' ,
@@ -1729,6 +1735,9 @@ def get_parser(prog='pep8', version=__version__):
17291735 default = MAX_LINE_LENGTH ,
17301736 help = "set maximum allowed line length "
17311737 "(default: %default)" )
1738+ parser .add_option ('--hang-closing' , action = 'store_true' ,
1739+ help = "hang closing bracket instead of matching "
1740+ "indentation of opening bracket's line" )
17321741 parser .add_option ('--format' , metavar = 'format' , default = 'default' ,
17331742 help = "set the error format [default|pylint|<custom>]" )
17341743 parser .add_option ('--diff' , action = 'store_true' ,
0 commit comments