]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/black/tests/data/cases/preview_long_strings.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '882d8795c6ff65c02f2657e596391748d1b6b7f5'
[etc/vim.git] / .vim / bundle / black / tests / data / cases / preview_long_strings.py
1 # flags: --preview
2 x = "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
3
4 x += "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
5
6 y = (
7     'Short string'
8 )
9
10 print('This is a really long string inside of a print statement with extra arguments attached at the end of it.', x, y, z)
11
12 print("This is a really long string inside of a print statement with no extra arguments attached at the end of it.")
13
14 D1 = {"The First": "This is a really long string that can't possibly be expected to fit all together on one line. Also it is inside a dictionary, so formatting is more difficult.", "The Second": "This is another really really (not really) long string that also can't be expected to fit on one line and is, like the other string, inside a dictionary."}
15
16 D2 = {1.0: "This is a really long string that can't possibly be expected to fit all together on one line. Also it is inside a dictionary, so formatting is more difficult.", 2.0: "This is another really really (not really) long string that also can't be expected to fit on one line and is, like the other string, inside a dictionary."}
17
18 D3 = {x: "This is a really long string that can't possibly be expected to fit all together on one line. Also it is inside a dictionary, so formatting is more difficult.", y: "This is another really really (not really) long string that also can't be expected to fit on one line and is, like the other string, inside a dictionary."}
19
20 D4 = {"A long and ridiculous {}".format(string_key): "This is a really really really long string that has to go i,side of a dictionary. It is soooo bad.", some_func("calling", "some", "stuff"): "This is a really really really long string that has to go inside of a dictionary. It is {soooo} bad (#{x}).".format(sooo="soooo", x=2), "A %s %s" % ("formatted", "string"): "This is a really really really long string that has to go inside of a dictionary. It is %s bad (#%d)." % ("soooo", 2)}
21
22 D5 = {  # Test for https://github.com/psf/black/issues/3261
23     ("This is a really long string that can't be expected to fit in one line and is used as a nested dict's key"): {"inner": "value"},
24 }
25
26 D6 = {  # Test for https://github.com/psf/black/issues/3261
27     ("This is a really long string that can't be expected to fit in one line and is used as a dict's key"): ["value1", "value2"],
28 }
29
30 L1 = ["The is a short string", "This is a really long string that can't possibly be expected to fit all together on one line. Also it is inside a list literal, so it's expected to be wrapped in parens when splitting to avoid implicit str concatenation.", short_call("arg", {"key": "value"}), "This is another really really (not really) long string that also can't be expected to fit on one line and is, like the other string, inside a list literal.", ("parens should be stripped for short string in list")]
31
32 L2 = ["This is a really long string that can't be expected to fit in one line and is the only child of a list literal."]
33
34 S1 = {"The is a short string", "This is a really long string that can't possibly be expected to fit all together on one line. Also it is inside a set literal, so it's expected to be wrapped in parens when splitting to avoid implicit str concatenation.", short_call("arg", {"key": "value"}), "This is another really really (not really) long string that also can't be expected to fit on one line and is, like the other string, inside a set literal.", ("parens should be stripped for short string in set")}
35
36 S2 = {"This is a really long string that can't be expected to fit in one line and is the only child of a set literal."}
37
38 T1 = ("The is a short string", "This is a really long string that can't possibly be expected to fit all together on one line. Also it is inside a tuple literal, so it's expected to be wrapped in parens when splitting to avoid implicit str concatenation.", short_call("arg", {"key": "value"}), "This is another really really (not really) long string that also can't be expected to fit on one line and is, like the other string, inside a tuple literal.", ("parens should be stripped for short string in list"))
39
40 T2 = ("This is a really long string that can't be expected to fit in one line and is the only child of a tuple literal.",)
41
42 func_with_keywords(my_arg, my_kwarg="Long keyword strings also need to be wrapped, but they will probably need to be handled a little bit differently.")
43
44 bad_split1 = (
45     'But what should happen when code has already been formatted but in the wrong way? Like'
46     " with a space at the end instead of the beginning. Or what about when it is split too soon?"
47 )
48
49 bad_split2 = "But what should happen when code has already " \
50              "been formatted but in the wrong way? Like " \
51              "with a space at the end instead of the " \
52              "beginning. Or what about when it is split too " \
53              "soon? In the case of a split that is too " \
54              "short, black will try to honer the custom " \
55              "split."
56
57 bad_split3 = (
58     "What if we have inline comments on "  # First Comment
59     "each line of a bad split? In that "  # Second Comment
60     "case, we should just leave it alone."  # Third Comment
61 )
62
63 bad_split_func1(
64     "But what should happen when code has already "
65     "been formatted but in the wrong way? Like "
66     "with a space at the end instead of the "
67     "beginning. Or what about when it is split too "
68     "soon? In the case of a split that is too "
69     "short, black will try to honer the custom "
70     "split.",
71     xxx, yyy, zzz
72 )
73
74 bad_split_func2(
75     xxx, yyy, zzz,
76     long_string_kwarg="But what should happen when code has already been formatted but in the wrong way? Like "
77                       "with a space at the end instead of the beginning. Or what about when it is split too "
78                       "soon?",
79 )
80
81 bad_split_func3(
82     (
83         "But what should happen when code has already "
84         r"been formatted but in the wrong way? Like "
85         "with a space at the end instead of the "
86         r"beginning. Or what about when it is split too "
87         r"soon? In the case of a split that is too "
88         "short, black will try to honer the custom "
89         "split."
90     ),
91     xxx,
92     yyy,
93     zzz,
94 )
95
96 inline_comments_func1(
97     "if there are inline "
98     "comments in the middle "
99     # Here is the standard alone comment.
100     "of the implicitly concatenated "
101     "string, we should handle "
102     "them correctly",
103     xxx,
104 )
105
106 inline_comments_func2(
107     "what if the string is very very very very very very very very very very long and this part does "
108     "not fit into a single line? "
109     # Here is the standard alone comment.
110     "then the string should still be properly handled by merging and splitting "
111     "it into parts that fit in line length.",
112     xxx,
113 )
114
115 raw_string = r"This is a long raw string. When re-formatting this string, black needs to make sure it prepends the 'r' onto the new string."
116
117 fmt_string1 = "We also need to be sure to preserve any and all {} which may or may not be attached to the string in question.".format("method calls")
118
119 fmt_string2 = "But what about when the string is {} but {}".format("short", "the method call is really really really really really really really really long?")
120
121 old_fmt_string1 = "While we are on the topic of %s, we should also note that old-style formatting must also be preserved, since some %s still uses it." % ("formatting", "code")
122
123 old_fmt_string2 = "This is a %s %s %s %s" % ("really really really really really", "old", "way to format strings!", "Use f-strings instead!")
124
125 old_fmt_string3 = "Whereas only the strings after the percent sign were long in the last example, this example uses a long initial string as well. This is another %s %s %s %s" % ("really really really really really", "old", "way to format strings!", "Use f-strings instead!")
126
127 fstring = f"f-strings definitely make things more {difficult} than they need to be for {{black}}. But boy they sure are handy. The problem is that some lines will need to have the 'f' whereas others do not. This {line}, for example, needs one."
128
129 fstring_with_no_fexprs = f"Some regular string that needs to get split certainly but is NOT an fstring by any means whatsoever."
130
131 comment_string = "Long lines with inline comments should have their comments appended to the reformatted string's enclosing right parentheses."  # This comment gets thrown to the top.
132
133 arg_comment_string = print("Long lines with inline comments which are apart of (and not the only member of) an argument list should have their comments appended to the reformatted string's enclosing left parentheses.",  # This comment gets thrown to the top.
134     "Arg #2", "Arg #3", "Arg #4", "Arg #5")
135
136 pragma_comment_string1 = "Lines which end with an inline pragma comment of the form `# <pragma>: <...>` should be left alone."  # noqa: E501
137
138 pragma_comment_string2 = "Lines which end with an inline pragma comment of the form `# <pragma>: <...>` should be left alone."  # noqa
139
140 """This is a really really really long triple quote string and it should not be touched."""
141
142 triple_quote_string = """This is a really really really long triple quote string assignment and it should not be touched."""
143
144 assert some_type_of_boolean_expression, "Followed by a really really really long string that is used to provide context to the AssertionError exception."
145
146 assert some_type_of_boolean_expression, "Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic string {}.".format("formatting")
147
148 assert some_type_of_boolean_expression, "Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic string %s." % "formatting"
149
150 assert some_type_of_boolean_expression, "Followed by a really really really long string that is used to provide context to the AssertionError exception, which uses dynamic %s %s." % ("string", "formatting")
151
152 some_function_call("With a reallly generic name and with a really really long string that is, at some point down the line, " + added + " to a variable and then added to another string.")
153
154 some_function_call("With a reallly generic name and with a really really long string that is, at some point down the line, " + added + " to a variable and then added to another string. But then what happens when the final string is also supppppperrrrr long?! Well then that second (realllllllly long) string should be split too.", "and a second argument", and_a_third)
155
156 return "A really really really really really really really really really really really really really long {} {}".format("return", "value")
157
158 func_with_bad_comma(
159     "This is a really long string argument to a function that has a trailing comma which should NOT be there.",
160 )
161
162 func_with_bad_comma(
163     "This is a really long string argument to a function that has a trailing comma which should NOT be there.", # comment after comma
164 )
165
166 func_with_bad_comma(
167     (
168         "This is a really long string argument to a function that has a trailing comma"
169         " which should NOT be there."
170     ),
171 )
172
173 func_with_bad_comma(
174     (
175         "This is a really long string argument to a function that has a trailing comma"
176         " which should NOT be there."
177     ), # comment after comma
178 )
179
180 func_with_bad_parens_that_wont_fit_in_one_line(
181     ("short string that should have parens stripped"),
182     x,
183     y,
184     z
185 )
186
187 func_with_bad_parens_that_wont_fit_in_one_line(
188     x,
189     y,
190     ("short string that should have parens stripped"),
191     z
192 )
193
194 func_with_bad_parens(
195     ("short string that should have parens stripped"),
196     x,
197     y,
198     z,
199 )
200
201 func_with_bad_parens(
202     x,
203     y,
204     ("short string that should have parens stripped"),
205     z,
206 )
207
208 annotated_variable: Final = "This is a large " + STRING + " that has been " + CONCATENATED + "using the '+' operator."
209 annotated_variable: Final = "This is a large string that has a type annotation attached to it. A type annotation should NOT stop a long string from being wrapped."
210 annotated_variable: Literal["fakse_literal"] = "This is a large string that has a type annotation attached to it. A type annotation should NOT stop a long string from being wrapped."
211
212 backslashes = "This is a really long string with \"embedded\" double quotes and 'single' quotes that also handles checking for an even number of backslashes \\"
213 backslashes = "This is a really long string with \"embedded\" double quotes and 'single' quotes that also handles checking for an even number of backslashes \\\\"
214 backslashes = "This is a really 'long' string with \"embedded double quotes\" and 'single' quotes that also handles checking for an odd number of backslashes \\\", like this...\\\\\\"
215
216 short_string = (
217     "Hi"
218     " there."
219 )
220
221 func_call(
222     short_string=(
223         "Hi"
224         " there."
225     )
226 )
227
228 raw_strings = r"Don't" " get" r" merged" " unless they are all raw."
229
230 def foo():
231     yield "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
232
233 x = f"This is a {{really}} long string that needs to be split without a doubt (i.e. most definitely). In short, this {string} that can't possibly be {{expected}} to fit all together on one line. In {fact} it may even take up three or more lines... like four or five... but probably just four."
234
235 long_unmergable_string_with_pragma = (
236     "This is a really long string that can't be merged because it has a likely pragma at the end"  # type: ignore
237     " of it."
238 )
239
240 long_unmergable_string_with_pragma = (
241     "This is a really long string that can't be merged because it has a likely pragma at the end"  # noqa
242     " of it."
243 )
244
245 long_unmergable_string_with_pragma = (
246     "This is a really long string that can't be merged because it has a likely pragma at the end"  # pylint: disable=some-pylint-check
247     " of it."
248 )
249
250 string_with_nameescape = (
251     "........................................................................ \N{LAO KO LA}"
252 )
253
254 string_with_nameescape = (
255     "........................................................................... \N{LAO KO LA}"
256 )
257
258 string_with_nameescape = (
259     "............................................................................ \N{LAO KO LA}"
260 )
261
262 string_with_nameescape_and_escaped_backslash = (
263     "...................................................................... \\\N{LAO KO LA}"
264 )
265
266 string_with_nameescape_and_escaped_backslash = (
267     "......................................................................... \\\N{LAO KO LA}"
268 )
269
270 string_with_nameescape_and_escaped_backslash = (
271     ".......................................................................... \\\N{LAO KO LA}"
272 )
273
274 string_with_escaped_nameescape = (
275     "........................................................................ \\N{LAO KO LA}"
276 )
277
278 string_with_escaped_nameescape = (
279     "........................................................................... \\N{LAO KO LA}"
280 )
281
282 msg = lambda x: f"this is a very very very long lambda value {x} that doesn't fit on a single line"
283
284 dict_with_lambda_values = {
285     "join": lambda j: (
286         f"{j.__class__.__name__}({some_function_call(j.left)}, "
287         f"{some_function_call(j.right)})"
288     ),
289 }
290
291 # Complex string concatenations with a method call in the middle.
292 code = (
293     ("    return [\n")
294     + (
295         ", \n".join(
296             "        (%r, self.%s, visitor.%s)"
297             % (attrname, attrname, visit_name)
298             for attrname, visit_name in names
299         )
300     )
301     + ("\n    ]\n")
302 )
303
304
305 # Test case of an outer string' parens enclose an inner string's parens.
306 call(body=("%s %s" % ((",".join(items)), suffix)))
307
308
309 # output
310
311
312 x = (
313     "This is a really long string that can't possibly be expected to fit all together"
314     " on one line. In fact it may even take up three or more lines... like four or"
315     " five... but probably just three."
316 )
317
318 x += (
319     "This is a really long string that can't possibly be expected to fit all together"
320     " on one line. In fact it may even take up three or more lines... like four or"
321     " five... but probably just three."
322 )
323
324 y = "Short string"
325
326 print(
327     "This is a really long string inside of a print statement with extra arguments"
328     " attached at the end of it.",
329     x,
330     y,
331     z,
332 )
333
334 print(
335     "This is a really long string inside of a print statement with no extra arguments"
336     " attached at the end of it."
337 )
338
339 D1 = {
340     "The First": (
341         "This is a really long string that can't possibly be expected to fit all"
342         " together on one line. Also it is inside a dictionary, so formatting is more"
343         " difficult."
344     ),
345     "The Second": (
346         "This is another really really (not really) long string that also can't be"
347         " expected to fit on one line and is, like the other string, inside a"
348         " dictionary."
349     ),
350 }
351
352 D2 = {
353     1.0: (
354         "This is a really long string that can't possibly be expected to fit all"
355         " together on one line. Also it is inside a dictionary, so formatting is more"
356         " difficult."
357     ),
358     2.0: (
359         "This is another really really (not really) long string that also can't be"
360         " expected to fit on one line and is, like the other string, inside a"
361         " dictionary."
362     ),
363 }
364
365 D3 = {
366     x: (
367         "This is a really long string that can't possibly be expected to fit all"
368         " together on one line. Also it is inside a dictionary, so formatting is more"
369         " difficult."
370     ),
371     y: (
372         "This is another really really (not really) long string that also can't be"
373         " expected to fit on one line and is, like the other string, inside a"
374         " dictionary."
375     ),
376 }
377
378 D4 = {
379     "A long and ridiculous {}".format(string_key): (
380         "This is a really really really long string that has to go i,side of a"
381         " dictionary. It is soooo bad."
382     ),
383     some_func("calling", "some", "stuff"): (
384         "This is a really really really long string that has to go inside of a"
385         " dictionary. It is {soooo} bad (#{x}).".format(sooo="soooo", x=2)
386     ),
387     "A %s %s"
388     % ("formatted", "string"): (
389         "This is a really really really long string that has to go inside of a"
390         " dictionary. It is %s bad (#%d)." % ("soooo", 2)
391     ),
392 }
393
394 D5 = {  # Test for https://github.com/psf/black/issues/3261
395     "This is a really long string that can't be expected to fit in one line and is used as a nested dict's key": {
396         "inner": "value"
397     },
398 }
399
400 D6 = {  # Test for https://github.com/psf/black/issues/3261
401     "This is a really long string that can't be expected to fit in one line and is used as a dict's key": [
402         "value1",
403         "value2",
404     ],
405 }
406
407 L1 = [
408     "The is a short string",
409     (
410         "This is a really long string that can't possibly be expected to fit all"
411         " together on one line. Also it is inside a list literal, so it's expected to"
412         " be wrapped in parens when splitting to avoid implicit str concatenation."
413     ),
414     short_call("arg", {"key": "value"}),
415     (
416         "This is another really really (not really) long string that also can't be"
417         " expected to fit on one line and is, like the other string, inside a list"
418         " literal."
419     ),
420     "parens should be stripped for short string in list",
421 ]
422
423 L2 = [
424     "This is a really long string that can't be expected to fit in one line and is the"
425     " only child of a list literal."
426 ]
427
428 S1 = {
429     "The is a short string",
430     (
431         "This is a really long string that can't possibly be expected to fit all"
432         " together on one line. Also it is inside a set literal, so it's expected to be"
433         " wrapped in parens when splitting to avoid implicit str concatenation."
434     ),
435     short_call("arg", {"key": "value"}),
436     (
437         "This is another really really (not really) long string that also can't be"
438         " expected to fit on one line and is, like the other string, inside a set"
439         " literal."
440     ),
441     "parens should be stripped for short string in set",
442 }
443
444 S2 = {
445     "This is a really long string that can't be expected to fit in one line and is the"
446     " only child of a set literal."
447 }
448
449 T1 = (
450     "The is a short string",
451     (
452         "This is a really long string that can't possibly be expected to fit all"
453         " together on one line. Also it is inside a tuple literal, so it's expected to"
454         " be wrapped in parens when splitting to avoid implicit str concatenation."
455     ),
456     short_call("arg", {"key": "value"}),
457     (
458         "This is another really really (not really) long string that also can't be"
459         " expected to fit on one line and is, like the other string, inside a tuple"
460         " literal."
461     ),
462     "parens should be stripped for short string in list",
463 )
464
465 T2 = (
466     (
467         "This is a really long string that can't be expected to fit in one line and is"
468         " the only child of a tuple literal."
469     ),
470 )
471
472 func_with_keywords(
473     my_arg,
474     my_kwarg=(
475         "Long keyword strings also need to be wrapped, but they will probably need to"
476         " be handled a little bit differently."
477     ),
478 )
479
480 bad_split1 = (
481     "But what should happen when code has already been formatted but in the wrong way?"
482     " Like with a space at the end instead of the beginning. Or what about when it is"
483     " split too soon?"
484 )
485
486 bad_split2 = (
487     "But what should happen when code has already "
488     "been formatted but in the wrong way? Like "
489     "with a space at the end instead of the "
490     "beginning. Or what about when it is split too "
491     "soon? In the case of a split that is too "
492     "short, black will try to honer the custom "
493     "split."
494 )
495
496 bad_split3 = (
497     "What if we have inline comments on "  # First Comment
498     "each line of a bad split? In that "  # Second Comment
499     "case, we should just leave it alone."  # Third Comment
500 )
501
502 bad_split_func1(
503     "But what should happen when code has already "
504     "been formatted but in the wrong way? Like "
505     "with a space at the end instead of the "
506     "beginning. Or what about when it is split too "
507     "soon? In the case of a split that is too "
508     "short, black will try to honer the custom "
509     "split.",
510     xxx,
511     yyy,
512     zzz,
513 )
514
515 bad_split_func2(
516     xxx,
517     yyy,
518     zzz,
519     long_string_kwarg=(
520         "But what should happen when code has already been formatted but in the wrong"
521         " way? Like with a space at the end instead of the beginning. Or what about"
522         " when it is split too soon?"
523     ),
524 )
525
526 bad_split_func3(
527     (
528         "But what should happen when code has already "
529         r"been formatted but in the wrong way? Like "
530         "with a space at the end instead of the "
531         r"beginning. Or what about when it is split too "
532         r"soon? In the case of a split that is too "
533         "short, black will try to honer the custom "
534         "split."
535     ),
536     xxx,
537     yyy,
538     zzz,
539 )
540
541 inline_comments_func1(
542     "if there are inline comments in the middle "
543     # Here is the standard alone comment.
544     "of the implicitly concatenated string, we should handle them correctly",
545     xxx,
546 )
547
548 inline_comments_func2(
549     "what if the string is very very very very very very very very very very long and"
550     " this part does not fit into a single line? "
551     # Here is the standard alone comment.
552     "then the string should still be properly handled by merging and splitting "
553     "it into parts that fit in line length.",
554     xxx,
555 )
556
557 raw_string = (
558     r"This is a long raw string. When re-formatting this string, black needs to make"
559     r" sure it prepends the 'r' onto the new string."
560 )
561
562 fmt_string1 = (
563     "We also need to be sure to preserve any and all {} which may or may not be"
564     " attached to the string in question.".format("method calls")
565 )
566
567 fmt_string2 = "But what about when the string is {} but {}".format(
568     "short",
569     "the method call is really really really really really really really really long?",
570 )
571
572 old_fmt_string1 = (
573     "While we are on the topic of %s, we should also note that old-style formatting"
574     " must also be preserved, since some %s still uses it." % ("formatting", "code")
575 )
576
577 old_fmt_string2 = "This is a %s %s %s %s" % (
578     "really really really really really",
579     "old",
580     "way to format strings!",
581     "Use f-strings instead!",
582 )
583
584 old_fmt_string3 = (
585     "Whereas only the strings after the percent sign were long in the last example,"
586     " this example uses a long initial string as well. This is another %s %s %s %s"
587     % (
588         "really really really really really",
589         "old",
590         "way to format strings!",
591         "Use f-strings instead!",
592     )
593 )
594
595 fstring = (
596     f"f-strings definitely make things more {difficult} than they need to be for"
597     " {black}. But boy they sure are handy. The problem is that some lines will need"
598     f" to have the 'f' whereas others do not. This {line}, for example, needs one."
599 )
600
601 fstring_with_no_fexprs = (
602     f"Some regular string that needs to get split certainly but is NOT an fstring by"
603     f" any means whatsoever."
604 )
605
606 comment_string = (  # This comment gets thrown to the top.
607     "Long lines with inline comments should have their comments appended to the"
608     " reformatted string's enclosing right parentheses."
609 )
610
611 arg_comment_string = print(
612     "Long lines with inline comments which are apart of (and not the only member of) an"
613     " argument list should have their comments appended to the reformatted string's"
614     " enclosing left parentheses.",  # This comment gets thrown to the top.
615     "Arg #2",
616     "Arg #3",
617     "Arg #4",
618     "Arg #5",
619 )
620
621 pragma_comment_string1 = "Lines which end with an inline pragma comment of the form `# <pragma>: <...>` should be left alone."  # noqa: E501
622
623 pragma_comment_string2 = "Lines which end with an inline pragma comment of the form `# <pragma>: <...>` should be left alone."  # noqa
624
625 """This is a really really really long triple quote string and it should not be touched."""
626
627 triple_quote_string = """This is a really really really long triple quote string assignment and it should not be touched."""
628
629 assert some_type_of_boolean_expression, (
630     "Followed by a really really really long string that is used to provide context to"
631     " the AssertionError exception."
632 )
633
634 assert some_type_of_boolean_expression, (
635     "Followed by a really really really long string that is used to provide context to"
636     " the AssertionError exception, which uses dynamic string {}.".format("formatting")
637 )
638
639 assert some_type_of_boolean_expression, (
640     "Followed by a really really really long string that is used to provide context to"
641     " the AssertionError exception, which uses dynamic string %s." % "formatting"
642 )
643
644 assert some_type_of_boolean_expression, (
645     "Followed by a really really really long string that is used to provide context to"
646     " the AssertionError exception, which uses dynamic %s %s."
647     % ("string", "formatting")
648 )
649
650 some_function_call(
651     "With a reallly generic name and with a really really long string that is, at some"
652     " point down the line, "
653     + added
654     + " to a variable and then added to another string."
655 )
656
657 some_function_call(
658     "With a reallly generic name and with a really really long string that is, at some"
659     " point down the line, "
660     + added
661     + " to a variable and then added to another string. But then what happens when the"
662     " final string is also supppppperrrrr long?! Well then that second (realllllllly"
663     " long) string should be split too.",
664     "and a second argument",
665     and_a_third,
666 )
667
668 return (
669     "A really really really really really really really really really really really"
670     " really really long {} {}".format("return", "value")
671 )
672
673 func_with_bad_comma(
674     "This is a really long string argument to a function that has a trailing comma"
675     " which should NOT be there.",
676 )
677
678 func_with_bad_comma(
679     "This is a really long string argument to a function that has a trailing comma"
680     " which should NOT be there.",  # comment after comma
681 )
682
683 func_with_bad_comma(
684     "This is a really long string argument to a function that has a trailing comma"
685     " which should NOT be there.",
686 )
687
688 func_with_bad_comma(
689     "This is a really long string argument to a function that has a trailing comma"
690     " which should NOT be there.",  # comment after comma
691 )
692
693 func_with_bad_parens_that_wont_fit_in_one_line(
694     "short string that should have parens stripped", x, y, z
695 )
696
697 func_with_bad_parens_that_wont_fit_in_one_line(
698     x, y, "short string that should have parens stripped", z
699 )
700
701 func_with_bad_parens(
702     "short string that should have parens stripped",
703     x,
704     y,
705     z,
706 )
707
708 func_with_bad_parens(
709     x,
710     y,
711     "short string that should have parens stripped",
712     z,
713 )
714
715 annotated_variable: Final = (
716     "This is a large "
717     + STRING
718     + " that has been "
719     + CONCATENATED
720     + "using the '+' operator."
721 )
722 annotated_variable: Final = (
723     "This is a large string that has a type annotation attached to it. A type"
724     " annotation should NOT stop a long string from being wrapped."
725 )
726 annotated_variable: Literal["fakse_literal"] = (
727     "This is a large string that has a type annotation attached to it. A type"
728     " annotation should NOT stop a long string from being wrapped."
729 )
730
731 backslashes = (
732     "This is a really long string with \"embedded\" double quotes and 'single' quotes"
733     " that also handles checking for an even number of backslashes \\"
734 )
735 backslashes = (
736     "This is a really long string with \"embedded\" double quotes and 'single' quotes"
737     " that also handles checking for an even number of backslashes \\\\"
738 )
739 backslashes = (
740     "This is a really 'long' string with \"embedded double quotes\" and 'single' quotes"
741     ' that also handles checking for an odd number of backslashes \\", like'
742     " this...\\\\\\"
743 )
744
745 short_string = "Hi there."
746
747 func_call(short_string="Hi there.")
748
749 raw_strings = r"Don't" " get" r" merged" " unless they are all raw."
750
751
752 def foo():
753     yield (
754         "This is a really long string that can't possibly be expected to fit all"
755         " together on one line. In fact it may even take up three or more lines... like"
756         " four or five... but probably just three."
757     )
758
759
760 x = (
761     "This is a {really} long string that needs to be split without a doubt (i.e."
762     f" most definitely). In short, this {string} that can't possibly be {{expected}} to"
763     f" fit all together on one line. In {fact} it may even take up three or more"
764     " lines... like four or five... but probably just four."
765 )
766
767 long_unmergable_string_with_pragma = (
768     "This is a really long string that can't be merged because it has a likely pragma at the end"  # type: ignore
769     " of it."
770 )
771
772 long_unmergable_string_with_pragma = (
773     "This is a really long string that can't be merged because it has a likely pragma at the end"  # noqa
774     " of it."
775 )
776
777 long_unmergable_string_with_pragma = (
778     "This is a really long string that can't be merged because it has a likely pragma at the end"  # pylint: disable=some-pylint-check
779     " of it."
780 )
781
782 string_with_nameescape = (
783     "........................................................................"
784     " \N{LAO KO LA}"
785 )
786
787 string_with_nameescape = (
788     "..........................................................................."
789     " \N{LAO KO LA}"
790 )
791
792 string_with_nameescape = (
793     "............................................................................"
794     " \N{LAO KO LA}"
795 )
796
797 string_with_nameescape_and_escaped_backslash = (
798     "......................................................................"
799     " \\\N{LAO KO LA}"
800 )
801
802 string_with_nameescape_and_escaped_backslash = (
803     "........................................................................."
804     " \\\N{LAO KO LA}"
805 )
806
807 string_with_nameescape_and_escaped_backslash = (
808     ".........................................................................."
809     " \\\N{LAO KO LA}"
810 )
811
812 string_with_escaped_nameescape = (
813     "........................................................................ \\N{LAO"
814     " KO LA}"
815 )
816
817 string_with_escaped_nameescape = (
818     "..........................................................................."
819     " \\N{LAO KO LA}"
820 )
821
822 msg = (
823     lambda x: (
824         f"this is a very very very long lambda value {x} that doesn't fit on a single"
825         " line"
826     )
827 )
828
829 dict_with_lambda_values = {
830     "join": lambda j: (
831         f"{j.__class__.__name__}({some_function_call(j.left)}, "
832         f"{some_function_call(j.right)})"
833     ),
834 }
835
836 # Complex string concatenations with a method call in the middle.
837 code = (
838     "    return [\n"
839     + ", \n".join(
840         "        (%r, self.%s, visitor.%s)" % (attrname, attrname, visit_name)
841         for attrname, visit_name in names
842     )
843     + "\n    ]\n"
844 )
845
846
847 # Test case of an outer string' parens enclose an inner string's parens.
848 call(body="%s %s" % (",".join(items), suffix))