]> git.madduck.net Git - etc/vim.git/blob - tests/data/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:

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