File tree 3 files changed +19
-2
lines changed
3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 16
16
17
17
- ` if ` guards in ` case ` blocks are now wrapped in parentheses when the line is too long.
18
18
(#4269 )
19
+ - Stop moving multiline strings to a new line unless inside brackets (#4289 )
19
20
20
21
### Configuration
21
22
Original file line number Diff line number Diff line change @@ -858,11 +858,13 @@ def is_line_short_enough( # noqa: C901
858
858
return False
859
859
860
860
if leaf .bracket_depth <= max_level_to_update and leaf .type == token .COMMA :
861
- # Ignore non-nested trailing comma
861
+ # Inside brackets, ignore trailing comma
862
862
# directly after MLS/MLS-containing expression
863
863
ignore_ctxs : List [Optional [LN ]] = [None ]
864
864
ignore_ctxs += multiline_string_contexts
865
- if not (leaf .prev_sibling in ignore_ctxs and i == len (line .leaves ) - 1 ):
865
+ if (line .inside_brackets or leaf .bracket_depth > 0 ) and (
866
+ i != len (line .leaves ) - 1 or leaf .prev_sibling not in ignore_ctxs
867
+ ):
866
868
commas [leaf .bracket_depth ] += 1
867
869
if max_level_to_update != math .inf :
868
870
max_level_to_update = min (max_level_to_update , leaf .bracket_depth )
Original file line number Diff line number Diff line change @@ -175,6 +175,13 @@ def dastardly_default_value(
175
175
"c"
176
176
)
177
177
178
+ assert some_var == expected_result , """
179
+ test
180
+ """
181
+ assert some_var == expected_result , f"""
182
+ expected: { expected_result }
183
+ actual: { some_var } """
184
+
178
185
# output
179
186
"""cow
180
187
say""" ,
@@ -385,3 +392,10 @@ def dastardly_default_value(
385
392
)
386
393
387
394
this_will_also_become_one_line = "abc" # comment
395
+
396
+ assert some_var == expected_result , """
397
+ test
398
+ """
399
+ assert some_var == expected_result , f"""
400
+ expected: { expected_result }
401
+ actual: { some_var } """
You can’t perform that action at this time.
0 commit comments