@@ -382,7 +382,7 @@ def indentation(logical_line, previous_logical, indent_char,
382382
383383
384384def continued_indentation (logical_line , tokens , indent_level , hang_closing ,
385- noqa , verbose ):
385+ indent_char , noqa , verbose ):
386386 r"""
387387 Continuation lines should align wrapped elements either vertically using
388388 Python's implicit line joining inside parentheses, brackets and braces, or
@@ -420,6 +420,7 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
420420 indent_next = logical_line .endswith (':' )
421421
422422 row = depth = 0
423+ valid_hangs = (4 ,) if indent_char != '\t ' else (4 , 8 )
423424 # remember how many brackets were opened on each line
424425 parens = [0 ] * nrows
425426 # relative indents of physical lines
@@ -455,11 +456,11 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
455456 close_bracket = (token_type == tokenize .OP and text in ']})' )
456457
457458 # is the indent relative to an opening bracket line?
458- valid_hang = 4 if (hang_closing or not close_bracket ) else 0
459459 for open_row in reversed (open_rows [depth ]):
460- if rel_indent [row ] == rel_indent [open_row ] + valid_hang :
460+ hang = rel_indent [row ] - rel_indent [open_row ]
461+ hanging_indent = hang in valid_hangs
462+ if hanging_indent :
461463 break
462- hang = rel_indent [row ] - rel_indent [open_row ]
463464 # is there any chance of visual indent?
464465 visual_indent = (not close_bracket and hang > 0 and
465466 indent_chances .get (start [1 ]))
@@ -478,7 +479,7 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
478479 # visual indent is broken
479480 yield (start , "E128 continuation line "
480481 "under-indented for visual indent" )
481- elif hang == 4 or (indent_next and rel_indent [row ] == 8 ):
482+ elif hanging_indent or (indent_next and rel_indent [row ] == 8 ):
482483 # hanging indent is verified
483484 if close_bracket and not hang_closing :
484485 yield (start , "E123 closing bracket does not match "
0 commit comments