| 1 |
# flags: --unstable |
| 2 |
def foo_brackets(request): |
| 3 |
return JsonResponse( |
| 4 |
{ |
| 5 |
"var_1": foo, |
| 6 |
"var_2": bar, |
| 7 |
} |
| 8 |
) |
| 9 |
|
| 10 |
def foo_square_brackets(request): |
| 11 |
return JsonResponse( |
| 12 |
[ |
| 13 |
"var_1", |
| 14 |
"var_2", |
| 15 |
] |
| 16 |
) |
| 17 |
|
| 18 |
func({"a": 37, "b": 42, "c": 927, "aaaaaaaaaaaaaaaaaaaaaaaaa": 11111111111111111111111111111111111111111}) |
| 19 |
|
| 20 |
func(["random_string_number_one","random_string_number_two","random_string_number_three","random_string_number_four"]) |
| 21 |
|
| 22 |
func( |
| 23 |
{ |
| 24 |
# expand me |
| 25 |
'a':37, |
| 26 |
'b':42, |
| 27 |
'c':927 |
| 28 |
} |
| 29 |
) |
| 30 |
|
| 31 |
func( |
| 32 |
[ |
| 33 |
'a', |
| 34 |
'b', |
| 35 |
'c', |
| 36 |
] |
| 37 |
) |
| 38 |
|
| 39 |
func( |
| 40 |
[ |
| 41 |
'a', |
| 42 |
'b', |
| 43 |
'c', |
| 44 |
], |
| 45 |
) |
| 46 |
|
| 47 |
func( # a |
| 48 |
[ # b |
| 49 |
"c", # c |
| 50 |
"d", # d |
| 51 |
"e", # e |
| 52 |
] # f |
| 53 |
) # g |
| 54 |
|
| 55 |
func( # a |
| 56 |
{ # b |
| 57 |
"c": 1, # c |
| 58 |
"d": 2, # d |
| 59 |
"e": 3, # e |
| 60 |
} # f |
| 61 |
) # g |
| 62 |
|
| 63 |
func( |
| 64 |
# preserve me |
| 65 |
[ |
| 66 |
"c", |
| 67 |
"d", |
| 68 |
"e", |
| 69 |
] |
| 70 |
) |
| 71 |
|
| 72 |
func( |
| 73 |
[ # preserve me but hug brackets |
| 74 |
"c", |
| 75 |
"d", |
| 76 |
"e", |
| 77 |
] |
| 78 |
) |
| 79 |
|
| 80 |
func( |
| 81 |
[ |
| 82 |
# preserve me but hug brackets |
| 83 |
"c", |
| 84 |
"d", |
| 85 |
"e", |
| 86 |
] |
| 87 |
) |
| 88 |
|
| 89 |
func( |
| 90 |
[ |
| 91 |
"c", |
| 92 |
# preserve me but hug brackets |
| 93 |
"d", |
| 94 |
"e", |
| 95 |
] |
| 96 |
) |
| 97 |
|
| 98 |
func( |
| 99 |
[ |
| 100 |
"c", |
| 101 |
"d", |
| 102 |
"e", |
| 103 |
# preserve me but hug brackets |
| 104 |
] |
| 105 |
) |
| 106 |
|
| 107 |
func( |
| 108 |
[ |
| 109 |
"c", |
| 110 |
"d", |
| 111 |
"e", |
| 112 |
] # preserve me but hug brackets |
| 113 |
) |
| 114 |
|
| 115 |
func( |
| 116 |
[ |
| 117 |
"c", |
| 118 |
"d", |
| 119 |
"e", |
| 120 |
] |
| 121 |
# preserve me |
| 122 |
) |
| 123 |
|
| 124 |
func([x for x in "short line"]) |
| 125 |
func([x for x in "long line long line long line long line long line long line long line"]) |
| 126 |
func([x for x in [x for x in "long line long line long line long line long line long line long line"]]) |
| 127 |
|
| 128 |
foooooooooooooooooooo( |
| 129 |
[{c: n + 1 for c in range(256)} for n in range(100)] + [{}], {size} |
| 130 |
) |
| 131 |
|
| 132 |
baaaaaaaaaaaaar( |
| 133 |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], {x}, "a string", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
| 134 |
) |
| 135 |
|
| 136 |
nested_mapping = {"key": [{"a very long key 1": "with a very long value", "a very long key 2": "with a very long value"}]} |
| 137 |
explicit_exploding = [[["short", "line",],],] |
| 138 |
single_item_do_not_explode = Context({ |
| 139 |
"version": get_docs_version(), |
| 140 |
}) |
| 141 |
|
| 142 |
foo(*[str(i) for i in range(100000000000000000000000000000000000000000000000000000000000)]) |
| 143 |
|
| 144 |
foo( |
| 145 |
**{ |
| 146 |
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa": 1, |
| 147 |
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb": 2, |
| 148 |
"ccccccccccccccccccccccccccccccccc": 3, |
| 149 |
**other, |
| 150 |
} |
| 151 |
) |
| 152 |
|
| 153 |
foo(**{x: y for x, y in enumerate(["long long long long line","long long long long line"])}) |
| 154 |
|
| 155 |
# Edge case when deciding whether to hug the brackets without inner content. |
| 156 |
very_very_very_long_variable = very_very_very_long_module.VeryVeryVeryVeryLongClassName([[]]) |
| 157 |
|
| 158 |
for foo in ["a", "b"]: |
| 159 |
output.extend([ |
| 160 |
individual |
| 161 |
for |
| 162 |
# Foobar |
| 163 |
container in xs_by_y[foo] |
| 164 |
# Foobar |
| 165 |
for individual in container["nested"] |
| 166 |
]) |
| 167 |
|
| 168 |
# output |
| 169 |
def foo_brackets(request): |
| 170 |
return JsonResponse({ |
| 171 |
"var_1": foo, |
| 172 |
"var_2": bar, |
| 173 |
}) |
| 174 |
|
| 175 |
|
| 176 |
def foo_square_brackets(request): |
| 177 |
return JsonResponse([ |
| 178 |
"var_1", |
| 179 |
"var_2", |
| 180 |
]) |
| 181 |
|
| 182 |
|
| 183 |
func({ |
| 184 |
"a": 37, |
| 185 |
"b": 42, |
| 186 |
"c": 927, |
| 187 |
"aaaaaaaaaaaaaaaaaaaaaaaaa": 11111111111111111111111111111111111111111, |
| 188 |
}) |
| 189 |
|
| 190 |
func([ |
| 191 |
"random_string_number_one", |
| 192 |
"random_string_number_two", |
| 193 |
"random_string_number_three", |
| 194 |
"random_string_number_four", |
| 195 |
]) |
| 196 |
|
| 197 |
func({ |
| 198 |
# expand me |
| 199 |
"a": 37, |
| 200 |
"b": 42, |
| 201 |
"c": 927, |
| 202 |
}) |
| 203 |
|
| 204 |
func([ |
| 205 |
"a", |
| 206 |
"b", |
| 207 |
"c", |
| 208 |
]) |
| 209 |
|
| 210 |
func( |
| 211 |
[ |
| 212 |
"a", |
| 213 |
"b", |
| 214 |
"c", |
| 215 |
], |
| 216 |
) |
| 217 |
|
| 218 |
func([ # a # b |
| 219 |
"c", # c |
| 220 |
"d", # d |
| 221 |
"e", # e |
| 222 |
]) # f # g |
| 223 |
|
| 224 |
func({ # a # b |
| 225 |
"c": 1, # c |
| 226 |
"d": 2, # d |
| 227 |
"e": 3, # e |
| 228 |
}) # f # g |
| 229 |
|
| 230 |
func( |
| 231 |
# preserve me |
| 232 |
[ |
| 233 |
"c", |
| 234 |
"d", |
| 235 |
"e", |
| 236 |
] |
| 237 |
) |
| 238 |
|
| 239 |
func([ # preserve me but hug brackets |
| 240 |
"c", |
| 241 |
"d", |
| 242 |
"e", |
| 243 |
]) |
| 244 |
|
| 245 |
func([ |
| 246 |
# preserve me but hug brackets |
| 247 |
"c", |
| 248 |
"d", |
| 249 |
"e", |
| 250 |
]) |
| 251 |
|
| 252 |
func([ |
| 253 |
"c", |
| 254 |
# preserve me but hug brackets |
| 255 |
"d", |
| 256 |
"e", |
| 257 |
]) |
| 258 |
|
| 259 |
func([ |
| 260 |
"c", |
| 261 |
"d", |
| 262 |
"e", |
| 263 |
# preserve me but hug brackets |
| 264 |
]) |
| 265 |
|
| 266 |
func([ |
| 267 |
"c", |
| 268 |
"d", |
| 269 |
"e", |
| 270 |
]) # preserve me but hug brackets |
| 271 |
|
| 272 |
func( |
| 273 |
[ |
| 274 |
"c", |
| 275 |
"d", |
| 276 |
"e", |
| 277 |
] |
| 278 |
# preserve me |
| 279 |
) |
| 280 |
|
| 281 |
func([x for x in "short line"]) |
| 282 |
func( |
| 283 |
[x for x in "long line long line long line long line long line long line long line"] |
| 284 |
) |
| 285 |
func([ |
| 286 |
x |
| 287 |
for x in [ |
| 288 |
x |
| 289 |
for x in "long line long line long line long line long line long line long line" |
| 290 |
] |
| 291 |
]) |
| 292 |
|
| 293 |
foooooooooooooooooooo( |
| 294 |
[{c: n + 1 for c in range(256)} for n in range(100)] + [{}], {size} |
| 295 |
) |
| 296 |
|
| 297 |
baaaaaaaaaaaaar( |
| 298 |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], {x}, "a string", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
| 299 |
) |
| 300 |
|
| 301 |
nested_mapping = { |
| 302 |
"key": [{ |
| 303 |
"a very long key 1": "with a very long value", |
| 304 |
"a very long key 2": "with a very long value", |
| 305 |
}] |
| 306 |
} |
| 307 |
explicit_exploding = [ |
| 308 |
[ |
| 309 |
[ |
| 310 |
"short", |
| 311 |
"line", |
| 312 |
], |
| 313 |
], |
| 314 |
] |
| 315 |
single_item_do_not_explode = Context({ |
| 316 |
"version": get_docs_version(), |
| 317 |
}) |
| 318 |
|
| 319 |
foo(*[ |
| 320 |
str(i) for i in range(100000000000000000000000000000000000000000000000000000000000) |
| 321 |
]) |
| 322 |
|
| 323 |
foo(**{ |
| 324 |
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa": 1, |
| 325 |
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb": 2, |
| 326 |
"ccccccccccccccccccccccccccccccccc": 3, |
| 327 |
**other, |
| 328 |
}) |
| 329 |
|
| 330 |
foo(**{ |
| 331 |
x: y for x, y in enumerate(["long long long long line", "long long long long line"]) |
| 332 |
}) |
| 333 |
|
| 334 |
# Edge case when deciding whether to hug the brackets without inner content. |
| 335 |
very_very_very_long_variable = very_very_very_long_module.VeryVeryVeryVeryLongClassName( |
| 336 |
[[]] |
| 337 |
) |
| 338 |
|
| 339 |
for foo in ["a", "b"]: |
| 340 |
output.extend([ |
| 341 |
individual |
| 342 |
for |
| 343 |
# Foobar |
| 344 |
container in xs_by_y[foo] |
| 345 |
# Foobar |
| 346 |
for individual in container["nested"] |
| 347 |
]) |