@@ -203,7 +203,9 @@ def MustSplit(self):
203
203
# Allow the fallthrough code to handle the closing bracket.
204
204
if current != opening .matching_bracket :
205
205
# If the container doesn't fit in the current line, must split
206
- return not self ._ContainerFitsOnStartLine (opening )
206
+ if (subtypes .COMP_FOR not in current .subtypes and
207
+ not self ._ContainerFitsOnStartLine (opening )):
208
+ return True
207
209
208
210
if (self .stack [- 1 ].split_before_closing_bracket and
209
211
(current .value in '}]' and style .Get ('SPLIT_BEFORE_CLOSING_BRACKET' ) or
@@ -546,9 +548,14 @@ def SurroundedByParens(token):
546
548
return True
547
549
else :
548
550
# Split after the opening of a container if it doesn't fit on the
549
- # current line.
551
+ # current line, including checking for wrapping .
550
552
if not self ._FitsOnLine (previous , previous .matching_bracket ):
551
- return True
553
+ arg_lengths = _CalculateArgLengths (previous )
554
+ start_col = self .column + len (current .value ) + len (previous .value )
555
+ for length in arg_lengths :
556
+ length += start_col
557
+ if length > self .column_limit :
558
+ return True
552
559
553
560
###########################################################################
554
561
# Original Formatting Splitting
@@ -1106,10 +1113,8 @@ def _ContainerFitsOnStartLine(self, opening):
1106
1113
self .stack [- 1 ].indent ) <= self .column_limit
1107
1114
1108
1115
1109
- _COMPOUND_STMTS = frozenset ({
1110
- 'for' , 'while' , 'if' , 'elif' , 'with' , 'except' , 'def' , 'class' , 'match' ,
1111
- 'case'
1112
- })
1116
+ _COMPOUND_STMTS = frozenset ({'for' , 'while' , 'if' , 'elif' , 'with' , 'except' ,
1117
+ 'def' , 'class' , 'match' , 'case' })
1113
1118
1114
1119
1115
1120
def _IsCompoundStatement (token ):
0 commit comments