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

Vim plugin docs improvements (#3468)
[etc/vim.git] / tests / data / preview / long_strings__regression.py
1 class A:
2     def foo():
3         result = type(message)("")
4
5
6 # Don't merge multiline (e.g. triple-quoted) strings.
7 def foo():
8     query = (
9         """SELECT xxxxxxxxxxxxxxxxxxxx(xxx)"""
10         """ FROM xxxxxxxxxxxxxxxx WHERE xxxxxxxxxx AND xxx <> xxxxxxxxxxxxxx()""")
11
12 # There was a bug where tuples were being identified as long strings.
13 long_tuple = ('Apple', 'Berry', 'Cherry', 'Dill', 'Evergreen', 'Fig',
14            'Grape', 'Harry', 'Iglu', 'Jaguar')
15
16 stupid_format_method_bug = "Some really long string that just so happens to be the {} {} to force the 'format' method to hang over the line length boundary. This is pretty annoying.".format("perfect", "length")
17
18 class A:
19     def foo():
20         os.system("This is a regression test. xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxxx.".format("xxxxxxxxxx", "xxxxxx", "xxxxxxxxxx"))
21
22
23 class A:
24     def foo():
25         XXXXXXXXXXXX.append(
26             (
27                 "xxx_xxxxxxxxxx(xxxxx={}, xxxx={}, xxxxx, xxxx_xxxx_xxxxxxxxxx={})".format(
28                     xxxxx, xxxx, xxxx_xxxx_xxxxxxxxxx
29                 ),
30                 my_var,
31                 my_other_var,
32             )
33         )
34
35 class A:
36     class B:
37         def foo():
38             bar(
39                 (
40                     "[{}]: xxx_xxxxxxxxxx(xxxxx={}, xxxx={}, xxxxx={}"
41                     " xxxx_xxxx_xxxxxxxxxx={}, xxxx={})"
42                     .format(xxxx._xxxxxxxxxxxxxx, xxxxx, xxxx, xxxx_xxxx_xxxxxxxxxx, xxxxxxx)
43                 ),
44                 varX,
45                 varY,
46                 varZ,
47             )
48
49 def foo(xxxx):
50     for (xxx_xxxx, _xxx_xxx, _xxx_xxxxx, xxx_xxxx) in xxxx:
51         for xxx in xxx_xxxx:
52             assert ("x" in xxx) or (
53                 xxx in xxx_xxx_xxxxx
54             ), "{0} xxxxxxx xx {1}, xxx {1} xx xxx xx xxxx xx xxx xxxx: xxx xxxx {2}".format(
55                 xxx_xxxx, xxx, xxxxxx.xxxxxxx(xxx_xxx_xxxxx)
56             )
57
58 class A:
59     def disappearing_comment():
60         return (
61             (  # xx -x xxxxxxx xx xxx xxxxxxx.
62                 '{{xxx_xxxxxxxxxx_xxxxxxxx}} xxx xxxx'
63                 ' {} {{xxxx}} >&2'
64                 .format(
65                     "{xxxx} {xxxxxx}"
66                     if xxxxx.xx_xxxxxxxxxx
67                     else ( # Disappearing Comment
68                         "--xxxxxxx --xxxxxx=x --xxxxxx-xxxxx=xxxxxx"
69                         " --xxxxxx-xxxx=xxxxxxxxxxx.xxx"
70                     )
71                 )
72             ),
73             (x, y, z),
74         )
75
76 class A:
77     class B:
78         def foo():
79             xxxxx_xxxx(
80                 xx, "\t"
81                 "@xxxxxx '{xxxx_xxx}\t' > {xxxxxx_xxxx}.xxxxxxx;"
82                 "{xxxx_xxx} >> {xxxxxx_xxxx}.xxxxxxx 2>&1; xx=$$?;"
83                 "xxxx $$xx"
84                 .format(xxxx_xxx=xxxx_xxxxxxx, xxxxxx_xxxx=xxxxxxx + "/" + xxxx_xxx_xxxx, x=xxx_xxxxx_xxxxx_xxx),
85                 x,
86                 y,
87                 z,
88             )
89
90 func_call_where_string_arg_has_method_call_and_bad_parens(
91     (
92         "A long string with {}. This string is so long that it is ridiculous. It can't fit on one line at alllll.".format("formatting")
93     ),
94 )
95
96 func_call_where_string_arg_has_old_fmt_and_bad_parens(
97     (
98         "A long string with {}. This string is so long that it is ridiculous. It can't fit on one line at alllll." % "formatting"
99     ),
100 )
101
102 func_call_where_string_arg_has_old_fmt_and_bad_parens(
103     (
104         "A long string with {}. This {} is so long that it is ridiculous. It can't fit on one line at alllll." % ("formatting", "string")
105     ),
106 )
107
108 class A:
109     def append(self):
110         if True:
111             xxxx.xxxxxxx.xxxxx( ('xxxxxxxxxx xxxx xx xxxxxx(%x) xx %x xxxx xx xxx %x.xx'
112                                  % (len(self) + 1,
113                                     xxxx.xxxxxxxxxx,
114                                     xxxx.xxxxxxxxxx))
115                                 + (' %.3f (%s) to %.3f (%s).\n'
116                                    % (xxxx.xxxxxxxxx,
117                                       xxxx.xxxxxxxxxxxxxx(xxxx.xxxxxxxxx),
118                                       x,
119                                       xxxx.xxxxxxxxxxxxxx( xx)
120                                       )))
121
122 class A:
123     def foo():
124         some_func_call(
125             'xxxxxxxxxx',
126             (
127                 "xx {xxxxxxxxxxx}/xxxxxxxxxxx.xxx xxxx.xxx && xxxxxx -x "
128                 "\"xxxx xxxxxxx xxxxxx xxxx; xxxx xxxxxx_xxxxx xxxxxx xxxx; "
129                 "xxxx.xxxx_xxxxxx(['xxxx.xxx'], xxxx.xxxxxxx().xxxxxxxxxx)\" "
130             ),
131             None,
132             ('xxxxxxxxxxx',),
133         ),
134
135 class A:
136     def foo():
137         some_func_call(
138             (
139                 "xx {xxxxxxxxxxx}/xxxxxxxxxxx.xxx xxxx.xxx && xxxxxx -x "
140                 "xxxx, ('xxxxxxx xxxxxx xxxx, xxxx') xxxxxx_xxxxx xxxxxx xxxx; "
141                 "xxxx.xxxx_xxxxxx(['xxxx.xxx'], xxxx.xxxxxxx().xxxxxxxxxx)\" "
142             ),
143             None,
144             ('xxxxxxxxxxx',),
145         ),
146
147 xxxxxxx = { 'xx' : 'xxxx xxxxxxx xxxxxxxxx -x xxx -x /xxx/{0} -x xxx,xxx -xx {1} \
148 -xx {1} -xx xxx=xxx_xxxx,xxx_xx,xxx_xxx,xxx_xxxx,xxx_xx,xxx_xxx |\
149  xxxxxx -x xxxxxxxx -x xxxxxxxx -x',
150          'xx' : 'xxxx xxxxxxx xxxxxxxxx -x xxx -x /xxx/{0} -x xxx,xxx -xx {1} \
151 -xx {1} -xx xxx=xxx_xxxx_xxx_xxxx,xxx_xx_xxx_xxxx,xxx_xxxx_xxx_xxxx,\
152 xxx_xx_xxxx_xxxx,xxx_xxx_xxxx,xxx_xxx_xxxx xxxx=xxx | xxxxxx -x xxxxxxxx -x xxxxxxxx -x'
153 }
154
155 class A:
156     def foo(self):
157         if True:
158             xxxxx_xxxxxxxxxxxx('xxx xxxxxx xxx xxxxxxxxx.xx xx xxxxxxxx.  xxx xxxxxxxxxxxxx.xx xxxxxxx '
159                                + 'xx xxxxxx xxxxxx xxxxxx xx xxxxxxx xxx xxx ${0} xx x xxxxxxxx xxxxx'.xxxxxx(xxxxxx_xxxxxx_xxx))
160
161 class A:
162     class B:
163         def foo():
164             row = {
165                 'xxxxxxxxxxxxxxx' : xxxxxx_xxxxx_xxxx,
166                 # 'xxxxxxxxxxxxxxxxxxxxxxx'
167                 # 'xxxxxxxxxxxxxxxxxxxxxx'
168                 # 'xxxxxxxxxxxxxxxxxx'
169                 # 'xxxxxxxxxxxxxxxxx'
170                 'xxxxxxxxxx' : xxxxx_xxxxx,
171                 }
172
173 class A:
174     def xxxx_xxx_xx_xxxxxxxxxx_xxxx_xxxxxxxxx(xxxx):
175         xxxxxxxx = [
176             xxxxxxxxxxxxxxxx(
177                 'xxxx',
178                 xxxxxxxxxxx={
179                     'xxxx' : 1.0,
180                 },
181                 xxxxxx={'xxxxxx 1' : xxxxxx(xxxx='xxxxxx 1', xxxxxx=600.0)},
182                 xxxxxxxx_xxxxxxx=0.0,
183             ),
184             xxxxxxxxxxxxxxxx(
185                 'xxxxxxx',
186                 xxxxxxxxxxx={
187                     'xxxx' : 1.0,
188                 },
189                 xxxxxx={'xxxxxx 1' : xxxxxx(xxxx='xxxxxx 1', xxxxxx=200.0)},
190                 xxxxxxxx_xxxxxxx=0.0,
191             ),
192             xxxxxxxxxxxxxxxx(
193                 'xxxx',
194             ),
195         ]
196
197 some_dictionary = {
198     'xxxxx006': ['xxx-xxx xxxxx3xxxx1xx2xxxxxxxxxxxxxx0xx6xxxxxxxxxx2xxxxxx9xxxxxxxxxx0xxxxx1xxx2x/xx9xx6+x+xxxxxxxxxxxxxx4xxxxxxxxxxxxxxxxxxxxx43xxx2xx2x4x++xxx6xxxxxxxxx+xxxxx/xx9x+xxxxxxxxxxxxxx8x15xxxxxxxxxxxxxxxxx82xx/xxxxxxxxxxxxxx/x5xxxxxxxxxxxxxx6xxxxxx74x4/xxx4x+xxxxxxxxx2xxxxxxxx87xxxxx4xxxxxxxx3xx0xxxxx4xxx1xx9xx5xxxxxxx/xxxxx5xx6xx4xxxx1x/x2xxxxxxxxxxxx64xxxxxxx1x0xx5xxxxxxxxxxxxxx== xxxxx000 xxxxxxxxxx\n',
199                  'xxx-xxx xxxxx3xxxx1xx2xxxxxxxxxxxxxx6xxxxxxxxxxxxxx9xxxxxxxxxxxxx3xxx9xxxxxxxxxxxxxxxx0xxxxxxxxxxxxxxxxx2xxxx2xxx6xxxxx/xx54xxxxxxxxx4xxx3xxxxxx9xx3xxxxx39xxxxxxxxx5xx91xxxx7xxxxxx8xxxxxxxxxxxxxxxx9xxx93xxxxxxxxxxxxxxxxx7xxx8xx8xx4/x1xxxxx1x3xxxxxxxxxxxxx3xxxxxx9xx4xx4x7xxxxxxxxxxxxx1xxxxxxxxx7xxxxxxxxxxxxxx4xx6xxxxxxxxx9xxx7xxxx2xxxxxxxxxxxxxxxxxxxxxx8xxxxxxxxxxxxxxxxxxxx6xx== xxxxx010 xxxxxxxxxx\n'],
200     'xxxxx016': ['xxx-xxx xxxxx3xxxx1xx2xxxxxxxxxxxxxx0xx6xxxxxxxxxx2xxxxxx9xxxxxxxxxx0xxxxx1xxx2x/xx9xx6+x+xxxxxxxxxxxxxx4xxxxxxxxxxxxxxxxxxxxx43xxx2xx2x4x++xxx6xxxxxxxxx+xxxxx/xx9x+xxxxxxxxxxxxxx8x15xxxxxxxxxxxxxxxxx82xx/xxxxxxxxxxxxxx/x5xxxxxxxxxxxxxx6xxxxxx74x4/xxx4x+xxxxxxxxx2xxxxxxxx87xxxxx4xxxxxxxx3xx0xxxxx4xxx1xx9xx5xxxxxxx/xxxxx5xx6xx4xxxx1x/x2xxxxxxxxxxxx64xxxxxxx1x0xx5xxxxxxxxxxxxxx== xxxxx000 xxxxxxxxxx\n',
201                  'xxx-xxx xxxxx3xxxx1xx2xxxxxxxxxxxxxx6xxxxxxxxxxxxxx9xxxxxxxxxxxxx3xxx9xxxxxxxxxxxxxxxx0xxxxxxxxxxxxxxxxx2xxxx2xxx6xxxxx/xx54xxxxxxxxx4xxx3xxxxxx9xx3xxxxx39xxxxxxxxx5xx91xxxx7xxxxxx8xxxxxxxxxxxxxxxx9xxx93xxxxxxxxxxxxxxxxx7xxx8xx8xx4/x1xxxxx1x3xxxxxxxxxxxxx3xxxxxx9xx4xx4x7xxxxxxxxxxxxx1xxxxxxxxx7xxxxxxxxxxxxxx4xx6xxxxxxxxx9xxx7xxxx2xxxxxxxxxxxxxxxxxxxxxx8xxxxxxxxxxxxxxxxxxxx6xx== xxxxx010 xxxxxxxxxx\n']
202 }
203
204 def foo():
205     xxx_xxx = (
206         'xxxx xxx xxxxxxxx_xxxx xx "xxxxxxxxxx".'
207         '\n xxx: xxxxxx xxxxxxxx_xxxx=xxxxxxxxxx'
208     ) # xxxx xxxxxxxxxx xxxx xx xxxx xx xxx xxxxxxxx xxxxxx xxxxx.
209
210 some_tuple = ("some string", "some string" " which should be joined")
211
212 some_commented_string = (
213     "This string is long but not so long that it needs hahahah toooooo be so greatttt"  # This comment gets thrown to the top.
214     " {} that I just can't think of any more good words to say about it at"
215     " allllllllllll".format("ha")  # comments here are fine
216 )
217
218 some_commented_string = (
219     "This string is long but not so long that it needs hahahah toooooo be so greatttt"  # But these
220     " {} that I just can't think of any more good words to say about it at"  # comments will stay
221     " allllllllllll".format("ha")  # comments here are fine
222 )
223
224 lpar_and_rpar_have_comments = func_call(  # LPAR Comment
225     "Long really ridiculous type of string that shouldn't really even exist at all. I mean commmme onnn!!!",  # Comma Comment
226 )  # RPAR Comment
227
228 cmd_fstring = (
229     f"sudo -E deluge-console info --detailed --sort-reverse=time_added "
230     f"{'' if ID is None else ID} | perl -nE 'print if /^{field}:/'"
231 )
232
233 cmd_fstring = f"sudo -E deluge-console info --detailed --sort-reverse=time_added {'' if ID is None else ID} | perl -nE 'print if /^{field}:/'"
234
235 cmd_fstring = f"sudo -E deluge-console info --detailed --sort-reverse=time_added {'{{}}' if ID is None else ID} | perl -nE 'print if /^{field}:/'"
236
237 cmd_fstring = f"sudo -E deluge-console info --detailed --sort-reverse=time_added {{'' if ID is None else ID}} | perl -nE 'print if /^{field}:/'"
238
239 fstring = f"This string really doesn't need to be an {{{{fstring}}}}, but this one most certainly, absolutely {does}."
240
241 fstring = (
242     f"We have to remember to escape {braces}."
243     " Like {these}."
244     f" But not {this}."
245 )
246
247 class A:
248     class B:
249         def foo():
250             st_error = STError(
251                 f"This string ({string_leaf.value}) appears to be pointless (i.e. has"
252                 " no parent)."
253             )
254
255 def foo():
256     user_regex = _lazy_re_compile(
257         r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*\Z"  # dot-atom
258         r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"\Z)',  # quoted-string
259         re.IGNORECASE)
260
261 def foo():
262     user_regex = _lazy_re_compile(
263         "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"  # dot-atom
264         'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',  # quoted-string
265         xyz
266     )
267
268 def foo():
269     user_regex = _lazy_re_compile(
270         "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"  # dot-atom
271         'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',  # quoted-string
272         xyz
273     )
274
275 class A:
276     class B:
277         def foo():
278             if not hasattr(module, name):
279                 raise ValueError(
280                     "Could not find object %s in %s.\n"
281                     "Please note that you cannot serialize things like inner "
282                     "classes. Please move the object into the main module "
283                     "body to use migrations.\n"
284                     "For more information, see "
285                     "https://docs.djangoproject.com/en/%s/topics/migrations/#serializing-values"
286                     % (name, module_name, get_docs_version()))
287
288 class A:
289     class B:
290         def foo():
291             if not hasattr(module, name):
292                 raise ValueError(
293                     "Could not find object %s in %s.\nPlease note that you cannot serialize things like inner classes. Please move the object into the main module body to use migrations.\nFor more information, see https://docs.djangoproject.com/en/%s/topics/migrations/#serializing-values"
294                     % (name, module_name, get_docs_version()))
295
296 x = (
297     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
298     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
299     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
300     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
301 )
302
303 class Step(StepBase):
304     def who(self):
305         self.cmd = 'SR AAAA-CORRECT NAME IS {last_name} {first_name}{middle_name} {title}/P{passenger_association}'.format(
306             last_name=last_name,
307             first_name=first_name,
308             middle_name=middle_name,
309             title=title,
310             passenger_association=passenger_association,
311         )
312
313 xxxxxxx_xxxxxx_xxxxxxx = xxx(
314     [
315         xxxxxxxxxxxx(
316             xxxxxx_xxxxxxx=(
317                 '((x.aaaaaaaaa = "xxxxxx.xxxxxxxxxxxxxxxxxxxxx") || (x.xxxxxxxxx = "xxxxxxxxxxxx")) && '
318                 # xxxxx xxxxxxxxxxxx xxxx xxx (xxxxxxxxxxxxxxxx) xx x xxxxxxxxx xx xxxxxx.
319                 "(x.bbbbbbbbbbbb.xxx != "
320                 '"xxx:xxx:xxx::cccccccccccc:xxxxxxx-xxxx/xxxxxxxxxxx/xxxxxxxxxxxxxxxxx") && '
321             )
322         )
323     ]
324 )
325
326 if __name__ == "__main__":
327     for i in range(4, 8):
328         cmd = (
329             r"for pid in $(ps aux | grep paster | grep -v grep | grep '\-%d' | awk '{print $2}'); do kill $pid; done"
330             % (i)
331         )
332
333 def A():
334     def B():
335         def C():
336             def D():
337                 def E():
338                     def F():
339                         def G():
340                             assert (
341                                 c_float(val[0][0] / val[0][1]).value
342                                 == c_float(value[0][0] / value[0][1]).value
343                             ), "%s didn't roundtrip" % tag
344
345 class xxxxxxxxxxxxxxxxxxxxx(xxxx.xxxxxxxxxxxxx):
346     def xxxxxxx_xxxxxx(xxxx):
347         assert xxxxxxx_xxxx in [
348             x.xxxxx.xxxxxx.xxxxx.xxxxxx,
349             x.xxxxx.xxxxxx.xxxxx.xxxx,
350         ], ("xxxxxxxxxxx xxxxxxx xxxx (xxxxxx xxxx) %x xxx xxxxx" % xxxxxxx_xxxx)
351
352 value.__dict__[
353     key
354 ] = "test"  # set some Thrift field to non-None in the struct aa bb cc dd ee
355
356 RE_ONE_BACKSLASH = {
357     "asdf_hjkl_jkl": re.compile(
358         r"(?<!([0-9]\ ))(?<=(^|\ ))([A-Z]+(\ )?|[0-9](\ )|[a-z](\ )){4,7}([A-Z]|[0-9]|[a-z])($|\b)(?!(\ ?([0-9]\ )|(\.)))"
359     ),
360 }
361
362 RE_TWO_BACKSLASHES = {
363     "asdf_hjkl_jkl": re.compile(
364         r"(?<!([0-9]\ ))(?<=(^|\ ))([A-Z]+(\ )?|[0-9](\ )|[a-z](\\ )){4,7}([A-Z]|[0-9]|[a-z])($|\b)(?!(\ ?([0-9]\ )|(\.)))"
365     ),
366 }
367
368 RE_THREE_BACKSLASHES = {
369     "asdf_hjkl_jkl": re.compile(
370         r"(?<!([0-9]\ ))(?<=(^|\ ))([A-Z]+(\ )?|[0-9](\ )|[a-z](\\\ )){4,7}([A-Z]|[0-9]|[a-z])($|\b)(?!(\ ?([0-9]\ )|(\.)))"
371     ),
372 }
373
374 # We do NOT split on f-string expressions.
375 print(f"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam. {[f'{i}' for i in range(10)]}")
376 x = f"This is a long string which contains an f-expr that should not split {{{[i for i in range(5)]}}}."
377
378 # The parens should NOT be removed in this case.
379 (
380     "my very long string that should get formatted if I'm careful to make sure it goes"
381     " over 88 characters which it has now"
382 )
383
384 # The parens should NOT be removed in this case.
385 (
386     "my very long string that should get formatted if I'm careful to make sure it goes over 88 characters which"
387     " it has now"
388 )
389
390 # The parens should NOT be removed in this case.
391 (
392     "my very long string"
393     " that should get formatted"
394     " if I'm careful to make sure"
395     " it goes over 88 characters which"
396     " it has now"
397 )
398
399
400 def _legacy_listen_examples():
401     text += (
402         "    \"listen for the '%(event_name)s' event\"\n"
403         "\n    # ... (event logic logic logic) ...\n"
404         % {
405             "since": since,
406         }
407     )
408
409
410 class X:
411     async def foo(self):
412         msg = ""
413         for candidate in CANDIDATES:
414             msg += (
415                 "**{candidate.object_type} {candidate.rev}**"
416                 " - {candidate.description}\n"
417             )
418
419
420 temp_msg = (
421     f"{f'{humanize_number(pos)}.': <{pound_len+2}} "
422     f"{balance: <{bal_len + 5}} "
423     f"<<{author.display_name}>>\n"
424 )
425
426 assert str(suffix_arr) == (
427     "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
428     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
429     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
430 )
431 assert str(suffix_arr) != (
432     "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
433     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
434     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
435 )
436 assert str(suffix_arr) <= (
437     "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
438     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
439     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
440 )
441 assert str(suffix_arr) >= (
442     "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
443     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
444     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
445 )
446 assert str(suffix_arr) < (
447     "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
448     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
449     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
450 )
451 assert str(suffix_arr) > (
452     "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
453     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
454     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
455 )
456 assert str(suffix_arr) in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
457 assert str(suffix_arr) not in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
458 message = (
459     f"1. Go to Google Developers Console and log in with your Google account."
460     "(https://console.developers.google.com/)"
461     "2. You should be prompted to create a new project (name does not matter)."
462     "3. Click on Enable APIs and Services at the top."
463     "4. In the list of APIs choose or search for YouTube Data API v3 and "
464     "click on it. Choose Enable."
465     "5. Click on Credentials on the left navigation bar."
466     "6. Click on Create Credential at the top."
467     '7. At the top click the link for "API key".'
468     "8. No application restrictions are needed. Click Create at the bottom."
469     "9. You now have a key to add to `{prefix}set api youtube api_key`"
470 )
471 message = (
472     f"1. Go to Google Developers Console and log in with your Google account."
473     "(https://console.developers.google.com/)"
474     "2. You should be prompted to create a new project (name does not matter)."
475     f"3. Click on Enable APIs and Services at the top."
476     "4. In the list of APIs choose or search for YouTube Data API v3 and "
477     "click on it. Choose Enable."
478     f"5. Click on Credentials on the left navigation bar."
479     "6. Click on Create Credential at the top."
480     '7. At the top click the link for "API key".'
481     "8. No application restrictions are needed. Click Create at the bottom."
482     "9. You now have a key to add to `{prefix}set api youtube api_key`"
483 )
484 message = (
485     f"1. Go to Google Developers Console and log in with your Google account."
486     "(https://console.developers.google.com/)"
487     "2. You should be prompted to create a new project (name does not matter)."
488     f"3. Click on Enable APIs and Services at the top."
489     "4. In the list of APIs choose or search for YouTube Data API v3 and "
490     "click on it. Choose Enable."
491     f"5. Click on Credentials on the left navigation bar."
492     "6. Click on Create Credential at the top."
493     '7. At the top click the link for "API key".'
494     "8. No application restrictions are needed. Click Create at the bottom."
495     f"9. You now have a key to add to `{prefix}set api youtube api_key`"
496 )
497
498 # It shouldn't matter if the string prefixes are capitalized.
499 temp_msg = (
500     F"{F'{humanize_number(pos)}.': <{pound_len+2}} "
501     F"{balance: <{bal_len + 5}} "
502     F"<<{author.display_name}>>\n"
503 )
504
505 fstring = (
506     F"We have to remember to escape {braces}."
507     " Like {these}."
508     F" But not {this}."
509 )
510
511 welcome_to_programming = R"hello," R" world!"
512
513 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."
514
515 x = F"This is a long string which contains an f-expr that should not split {{{[i for i in range(5)]}}}."
516
517 x = (
518     "\N{BLACK RIGHT-POINTING TRIANGLE WITH DOUBLE VERTICAL BAR}\N{VARIATION SELECTOR-16}"
519 )
520
521 xxxxxx_xxx_xxxx_xx_xxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxxxx_xxxx_xxxx_xxxxx = xxxx.xxxxxx.xxxxxxxxx.xxxxxxxxxxxxxxxxxxxx(
522     xx_xxxxxx={
523         "x3_xxxxxxxx": "xxx3_xxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxxxx_xxxxxxxx_xxxxxx_xxxxxxx",
524     },
525 )
526
527 # Regression test for https://github.com/psf/black/issues/3117.
528 some_dict = {
529     "something_something":
530         r"Lorem ipsum dolor sit amet, an sed convenire eloquentiam \t"
531         r"signiferumque, duo ea vocibus consetetur scriptorem. Facer \t",
532 }
533
534 # Regression test for https://github.com/psf/black/issues/3459.
535 xxxx(
536     empty_str_as_first_split=''
537     f'xxxxxxx {xxxxxxxxxx} xxx xxxxxxxxxx xxxxx xxx xxx xx '
538     'xxxxx xxxxxxxxx xxxxxxx, xxx xxxxxxxxxxx xxx xxxxx. '
539     f'xxxxxxxxxxxxx xxxx xx xxxxxxxxxx. xxxxx: {x.xxx}',
540     empty_u_str_as_first_split=u''
541     f'xxxxxxx {xxxxxxxxxx} xxx xxxxxxxxxx xxxxx xxx xxx xx '
542     'xxxxx xxxxxxxxx xxxxxxx, xxx xxxxxxxxxxx xxx xxxxx. '
543     f'xxxxxxxxxxxxx xxxx xx xxxxxxxxxx. xxxxx: {x.xxx}',
544 )
545
546 # Regression test for https://github.com/psf/black/issues/3455.
547 a_dict = {
548     "/this/is/a/very/very/very/very/very/very/very/very/very/very/long/key/without/spaces":
549         # And there is a comment before the value
550         ("item1", "item2", "item3"),
551 }
552
553
554 # output
555
556
557 class A:
558     def foo():
559         result = type(message)("")
560
561
562 # Don't merge multiline (e.g. triple-quoted) strings.
563 def foo():
564     query = (
565         """SELECT xxxxxxxxxxxxxxxxxxxx(xxx)"""
566         """ FROM xxxxxxxxxxxxxxxx WHERE xxxxxxxxxx AND xxx <> xxxxxxxxxxxxxx()"""
567     )
568
569
570 # There was a bug where tuples were being identified as long strings.
571 long_tuple = (
572     "Apple",
573     "Berry",
574     "Cherry",
575     "Dill",
576     "Evergreen",
577     "Fig",
578     "Grape",
579     "Harry",
580     "Iglu",
581     "Jaguar",
582 )
583
584 stupid_format_method_bug = (
585     "Some really long string that just so happens to be the {} {} to force the 'format'"
586     " method to hang over the line length boundary. This is pretty annoying.".format(
587         "perfect", "length"
588     )
589 )
590
591
592 class A:
593     def foo():
594         os.system(
595             "This is a regression test. xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx"
596             " xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx"
597             " xxxx.".format("xxxxxxxxxx", "xxxxxx", "xxxxxxxxxx")
598         )
599
600
601 class A:
602     def foo():
603         XXXXXXXXXXXX.append(
604             (
605                 "xxx_xxxxxxxxxx(xxxxx={}, xxxx={}, xxxxx, xxxx_xxxx_xxxxxxxxxx={})"
606                 .format(xxxxx, xxxx, xxxx_xxxx_xxxxxxxxxx),
607                 my_var,
608                 my_other_var,
609             )
610         )
611
612
613 class A:
614     class B:
615         def foo():
616             bar(
617                 "[{}]: xxx_xxxxxxxxxx(xxxxx={}, xxxx={}, xxxxx={}"
618                 " xxxx_xxxx_xxxxxxxxxx={}, xxxx={})".format(
619                     xxxx._xxxxxxxxxxxxxx, xxxxx, xxxx, xxxx_xxxx_xxxxxxxxxx, xxxxxxx
620                 ),
621                 varX,
622                 varY,
623                 varZ,
624             )
625
626
627 def foo(xxxx):
628     for xxx_xxxx, _xxx_xxx, _xxx_xxxxx, xxx_xxxx in xxxx:
629         for xxx in xxx_xxxx:
630             assert ("x" in xxx) or (xxx in xxx_xxx_xxxxx), (
631                 "{0} xxxxxxx xx {1}, xxx {1} xx xxx xx xxxx xx xxx xxxx: xxx xxxx {2}"
632                 .format(xxx_xxxx, xxx, xxxxxx.xxxxxxx(xxx_xxx_xxxxx))
633             )
634
635
636 class A:
637     def disappearing_comment():
638         return (
639             (  # xx -x xxxxxxx xx xxx xxxxxxx.
640                 "{{xxx_xxxxxxxxxx_xxxxxxxx}} xxx xxxx {} {{xxxx}} >&2".format(
641                     "{xxxx} {xxxxxx}"
642                     if xxxxx.xx_xxxxxxxxxx
643                     else (  # Disappearing Comment
644                         "--xxxxxxx --xxxxxx=x --xxxxxx-xxxxx=xxxxxx"
645                         " --xxxxxx-xxxx=xxxxxxxxxxx.xxx"
646                     )
647                 )
648             ),
649             (x, y, z),
650         )
651
652
653 class A:
654     class B:
655         def foo():
656             xxxxx_xxxx(
657                 xx,
658                 "\t"
659                 "@xxxxxx '{xxxx_xxx}\t' > {xxxxxx_xxxx}.xxxxxxx;"
660                 "{xxxx_xxx} >> {xxxxxx_xxxx}.xxxxxxx 2>&1; xx=$$?;"
661                 "xxxx $$xx".format(
662                     xxxx_xxx=xxxx_xxxxxxx,
663                     xxxxxx_xxxx=xxxxxxx + "/" + xxxx_xxx_xxxx,
664                     x=xxx_xxxxx_xxxxx_xxx,
665                 ),
666                 x,
667                 y,
668                 z,
669             )
670
671
672 func_call_where_string_arg_has_method_call_and_bad_parens(
673     "A long string with {}. This string is so long that it is ridiculous. It can't fit"
674     " on one line at alllll.".format("formatting"),
675 )
676
677 func_call_where_string_arg_has_old_fmt_and_bad_parens(
678     "A long string with {}. This string is so long that it is ridiculous. It can't fit"
679     " on one line at alllll." % "formatting",
680 )
681
682 func_call_where_string_arg_has_old_fmt_and_bad_parens(
683     "A long string with {}. This {} is so long that it is ridiculous. It can't fit on"
684     " one line at alllll." % ("formatting", "string"),
685 )
686
687
688 class A:
689     def append(self):
690         if True:
691             xxxx.xxxxxxx.xxxxx(
692                 "xxxxxxxxxx xxxx xx xxxxxx(%x) xx %x xxxx xx xxx %x.xx"
693                 % (len(self) + 1, xxxx.xxxxxxxxxx, xxxx.xxxxxxxxxx)
694                 + " %.3f (%s) to %.3f (%s).\n"
695                 % (
696                     xxxx.xxxxxxxxx,
697                     xxxx.xxxxxxxxxxxxxx(xxxx.xxxxxxxxx),
698                     x,
699                     xxxx.xxxxxxxxxxxxxx(xx),
700                 )
701             )
702
703
704 class A:
705     def foo():
706         some_func_call(
707             "xxxxxxxxxx",
708             (
709                 "xx {xxxxxxxxxxx}/xxxxxxxxxxx.xxx xxxx.xxx && xxxxxx -x "
710                 '"xxxx xxxxxxx xxxxxx xxxx; xxxx xxxxxx_xxxxx xxxxxx xxxx; '
711                 "xxxx.xxxx_xxxxxx(['xxxx.xxx'], xxxx.xxxxxxx().xxxxxxxxxx)\" "
712             ),
713             None,
714             ("xxxxxxxxxxx",),
715         ),
716
717
718 class A:
719     def foo():
720         some_func_call(
721             (
722                 "xx {xxxxxxxxxxx}/xxxxxxxxxxx.xxx xxxx.xxx && xxxxxx -x "
723                 "xxxx, ('xxxxxxx xxxxxx xxxx, xxxx') xxxxxx_xxxxx xxxxxx xxxx; "
724                 "xxxx.xxxx_xxxxxx(['xxxx.xxx'], xxxx.xxxxxxx().xxxxxxxxxx)\" "
725             ),
726             None,
727             ("xxxxxxxxxxx",),
728         ),
729
730
731 xxxxxxx = {
732     "xx": (
733         "xxxx xxxxxxx xxxxxxxxx -x xxx -x /xxx/{0} -x xxx,xxx -xx {1} -xx {1} -xx"
734         " xxx=xxx_xxxx,xxx_xx,xxx_xxx,xxx_xxxx,xxx_xx,xxx_xxx | xxxxxx -x xxxxxxxx -x"
735         " xxxxxxxx -x"
736     ),
737     "xx": (
738         "xxxx xxxxxxx xxxxxxxxx -x xxx -x /xxx/{0} -x xxx,xxx -xx {1} -xx {1} -xx"
739         " xxx=xxx_xxxx_xxx_xxxx,xxx_xx_xxx_xxxx,xxx_xxxx_xxx_xxxx,xxx_xx_xxxx_xxxx,xxx_xxx_xxxx,xxx_xxx_xxxx"
740         " xxxx=xxx | xxxxxx -x xxxxxxxx -x xxxxxxxx -x"
741     ),
742 }
743
744
745 class A:
746     def foo(self):
747         if True:
748             xxxxx_xxxxxxxxxxxx(
749                 "xxx xxxxxx xxx xxxxxxxxx.xx xx xxxxxxxx.  xxx xxxxxxxxxxxxx.xx"
750                 " xxxxxxx "
751                 + "xx xxxxxx xxxxxx xxxxxx xx xxxxxxx xxx xxx ${0} xx x xxxxxxxx xxxxx"
752                 .xxxxxx(xxxxxx_xxxxxx_xxx)
753             )
754
755
756 class A:
757     class B:
758         def foo():
759             row = {
760                 "xxxxxxxxxxxxxxx": xxxxxx_xxxxx_xxxx,
761                 # 'xxxxxxxxxxxxxxxxxxxxxxx'
762                 # 'xxxxxxxxxxxxxxxxxxxxxx'
763                 # 'xxxxxxxxxxxxxxxxxx'
764                 # 'xxxxxxxxxxxxxxxxx'
765                 "xxxxxxxxxx": xxxxx_xxxxx,
766             }
767
768
769 class A:
770     def xxxx_xxx_xx_xxxxxxxxxx_xxxx_xxxxxxxxx(xxxx):
771         xxxxxxxx = [
772             xxxxxxxxxxxxxxxx(
773                 "xxxx",
774                 xxxxxxxxxxx={
775                     "xxxx": 1.0,
776                 },
777                 xxxxxx={"xxxxxx 1": xxxxxx(xxxx="xxxxxx 1", xxxxxx=600.0)},
778                 xxxxxxxx_xxxxxxx=0.0,
779             ),
780             xxxxxxxxxxxxxxxx(
781                 "xxxxxxx",
782                 xxxxxxxxxxx={
783                     "xxxx": 1.0,
784                 },
785                 xxxxxx={"xxxxxx 1": xxxxxx(xxxx="xxxxxx 1", xxxxxx=200.0)},
786                 xxxxxxxx_xxxxxxx=0.0,
787             ),
788             xxxxxxxxxxxxxxxx(
789                 "xxxx",
790             ),
791         ]
792
793
794 some_dictionary = {
795     "xxxxx006": [
796         (
797             "xxx-xxx"
798             " xxxxx3xxxx1xx2xxxxxxxxxxxxxx0xx6xxxxxxxxxx2xxxxxx9xxxxxxxxxx0xxxxx1xxx2x/xx9xx6+x+xxxxxxxxxxxxxx4xxxxxxxxxxxxxxxxxxxxx43xxx2xx2x4x++xxx6xxxxxxxxx+xxxxx/xx9x+xxxxxxxxxxxxxx8x15xxxxxxxxxxxxxxxxx82xx/xxxxxxxxxxxxxx/x5xxxxxxxxxxxxxx6xxxxxx74x4/xxx4x+xxxxxxxxx2xxxxxxxx87xxxxx4xxxxxxxx3xx0xxxxx4xxx1xx9xx5xxxxxxx/xxxxx5xx6xx4xxxx1x/x2xxxxxxxxxxxx64xxxxxxx1x0xx5xxxxxxxxxxxxxx=="
799             " xxxxx000 xxxxxxxxxx\n"
800         ),
801         (
802             "xxx-xxx"
803             " xxxxx3xxxx1xx2xxxxxxxxxxxxxx6xxxxxxxxxxxxxx9xxxxxxxxxxxxx3xxx9xxxxxxxxxxxxxxxx0xxxxxxxxxxxxxxxxx2xxxx2xxx6xxxxx/xx54xxxxxxxxx4xxx3xxxxxx9xx3xxxxx39xxxxxxxxx5xx91xxxx7xxxxxx8xxxxxxxxxxxxxxxx9xxx93xxxxxxxxxxxxxxxxx7xxx8xx8xx4/x1xxxxx1x3xxxxxxxxxxxxx3xxxxxx9xx4xx4x7xxxxxxxxxxxxx1xxxxxxxxx7xxxxxxxxxxxxxx4xx6xxxxxxxxx9xxx7xxxx2xxxxxxxxxxxxxxxxxxxxxx8xxxxxxxxxxxxxxxxxxxx6xx=="
804             " xxxxx010 xxxxxxxxxx\n"
805         ),
806     ],
807     "xxxxx016": [
808         (
809             "xxx-xxx"
810             " xxxxx3xxxx1xx2xxxxxxxxxxxxxx0xx6xxxxxxxxxx2xxxxxx9xxxxxxxxxx0xxxxx1xxx2x/xx9xx6+x+xxxxxxxxxxxxxx4xxxxxxxxxxxxxxxxxxxxx43xxx2xx2x4x++xxx6xxxxxxxxx+xxxxx/xx9x+xxxxxxxxxxxxxx8x15xxxxxxxxxxxxxxxxx82xx/xxxxxxxxxxxxxx/x5xxxxxxxxxxxxxx6xxxxxx74x4/xxx4x+xxxxxxxxx2xxxxxxxx87xxxxx4xxxxxxxx3xx0xxxxx4xxx1xx9xx5xxxxxxx/xxxxx5xx6xx4xxxx1x/x2xxxxxxxxxxxx64xxxxxxx1x0xx5xxxxxxxxxxxxxx=="
811             " xxxxx000 xxxxxxxxxx\n"
812         ),
813         (
814             "xxx-xxx"
815             " xxxxx3xxxx1xx2xxxxxxxxxxxxxx6xxxxxxxxxxxxxx9xxxxxxxxxxxxx3xxx9xxxxxxxxxxxxxxxx0xxxxxxxxxxxxxxxxx2xxxx2xxx6xxxxx/xx54xxxxxxxxx4xxx3xxxxxx9xx3xxxxx39xxxxxxxxx5xx91xxxx7xxxxxx8xxxxxxxxxxxxxxxx9xxx93xxxxxxxxxxxxxxxxx7xxx8xx8xx4/x1xxxxx1x3xxxxxxxxxxxxx3xxxxxx9xx4xx4x7xxxxxxxxxxxxx1xxxxxxxxx7xxxxxxxxxxxxxx4xx6xxxxxxxxx9xxx7xxxx2xxxxxxxxxxxxxxxxxxxxxx8xxxxxxxxxxxxxxxxxxxx6xx=="
816             " xxxxx010 xxxxxxxxxx\n"
817         ),
818     ],
819 }
820
821
822 def foo():
823     xxx_xxx = (  # xxxx xxxxxxxxxx xxxx xx xxxx xx xxx xxxxxxxx xxxxxx xxxxx.
824         'xxxx xxx xxxxxxxx_xxxx xx "xxxxxxxxxx".\n xxx: xxxxxx xxxxxxxx_xxxx=xxxxxxxxxx'
825     )
826
827
828 some_tuple = ("some string", "some string which should be joined")
829
830 some_commented_string = (  # This comment gets thrown to the top.
831     "This string is long but not so long that it needs hahahah toooooo be so greatttt"
832     " {} that I just can't think of any more good words to say about it at"
833     " allllllllllll".format("ha")  # comments here are fine
834 )
835
836 some_commented_string = (
837     "This string is long but not so long that it needs hahahah toooooo be so greatttt"  # But these
838     " {} that I just can't think of any more good words to say about it at"  # comments will stay
839     " allllllllllll".format("ha")  # comments here are fine
840 )
841
842 lpar_and_rpar_have_comments = func_call(  # LPAR Comment
843     (  # Comma Comment
844         "Long really ridiculous type of string that shouldn't really even exist at all."
845         " I mean commmme onnn!!!"
846     ),
847 )  # RPAR Comment
848
849 cmd_fstring = (
850     "sudo -E deluge-console info --detailed --sort-reverse=time_added "
851     f"{'' if ID is None else ID} | perl -nE 'print if /^{field}:/'"
852 )
853
854 cmd_fstring = (
855     "sudo -E deluge-console info --detailed --sort-reverse=time_added"
856     f" {'' if ID is None else ID} | perl -nE 'print if /^{field}:/'"
857 )
858
859 cmd_fstring = (
860     "sudo -E deluge-console info --detailed --sort-reverse=time_added"
861     f" {'{{}}' if ID is None else ID} | perl -nE 'print if /^{field}:/'"
862 )
863
864 cmd_fstring = (
865     "sudo -E deluge-console info --detailed --sort-reverse=time_added {'' if ID is"
866     f" None else ID}} | perl -nE 'print if /^{field}:/'"
867 )
868
869 fstring = (
870     "This string really doesn't need to be an {{fstring}}, but this one most"
871     f" certainly, absolutely {does}."
872 )
873
874 fstring = f"We have to remember to escape {braces}. Like {{these}}. But not {this}."
875
876
877 class A:
878     class B:
879         def foo():
880             st_error = STError(
881                 f"This string ({string_leaf.value}) appears to be pointless (i.e. has"
882                 " no parent)."
883             )
884
885
886 def foo():
887     user_regex = _lazy_re_compile(
888         r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*\Z"  # dot-atom
889         r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"\Z)',  # quoted-string
890         re.IGNORECASE,
891     )
892
893
894 def foo():
895     user_regex = _lazy_re_compile(
896         "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"  # dot-atom
897         "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",  # quoted-string
898         xyz,
899     )
900
901
902 def foo():
903     user_regex = _lazy_re_compile(
904         "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"  # dot-atom
905         "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",  # quoted-string
906         xyz,
907     )
908
909
910 class A:
911     class B:
912         def foo():
913             if not hasattr(module, name):
914                 raise ValueError(
915                     "Could not find object %s in %s.\n"
916                     "Please note that you cannot serialize things like inner "
917                     "classes. Please move the object into the main module "
918                     "body to use migrations.\n"
919                     "For more information, see "
920                     "https://docs.djangoproject.com/en/%s/topics/migrations/#serializing-values"
921                     % (name, module_name, get_docs_version())
922                 )
923
924
925 class A:
926     class B:
927         def foo():
928             if not hasattr(module, name):
929                 raise ValueError(
930                     "Could not find object %s in %s.\nPlease note that you cannot"
931                     " serialize things like inner classes. Please move the object into"
932                     " the main module body to use migrations.\nFor more information,"
933                     " see https://docs.djangoproject.com/en/%s/topics/migrations/#serializing-values"
934                     % (name, module_name, get_docs_version())
935                 )
936
937
938 x = (
939     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
940     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
941     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
942     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
943 )
944
945
946 class Step(StepBase):
947     def who(self):
948         self.cmd = (
949             "SR AAAA-CORRECT NAME IS {last_name} {first_name}{middle_name}"
950             " {title}/P{passenger_association}".format(
951                 last_name=last_name,
952                 first_name=first_name,
953                 middle_name=middle_name,
954                 title=title,
955                 passenger_association=passenger_association,
956             )
957         )
958
959
960 xxxxxxx_xxxxxx_xxxxxxx = xxx(
961     [
962         xxxxxxxxxxxx(
963             xxxxxx_xxxxxxx=(
964                 '((x.aaaaaaaaa = "xxxxxx.xxxxxxxxxxxxxxxxxxxxx") || (x.xxxxxxxxx ='
965                 ' "xxxxxxxxxxxx")) && '
966                 # xxxxx xxxxxxxxxxxx xxxx xxx (xxxxxxxxxxxxxxxx) xx x xxxxxxxxx xx xxxxxx.
967                 "(x.bbbbbbbbbbbb.xxx != "
968                 '"xxx:xxx:xxx::cccccccccccc:xxxxxxx-xxxx/xxxxxxxxxxx/xxxxxxxxxxxxxxxxx") && '
969             )
970         )
971     ]
972 )
973
974 if __name__ == "__main__":
975     for i in range(4, 8):
976         cmd = (
977             r"for pid in $(ps aux | grep paster | grep -v grep | grep '\-%d' | awk"
978             r" '{print $2}'); do kill $pid; done" % (i)
979         )
980
981
982 def A():
983     def B():
984         def C():
985             def D():
986                 def E():
987                     def F():
988                         def G():
989                             assert (
990                                 c_float(val[0][0] / val[0][1]).value
991                                 == c_float(value[0][0] / value[0][1]).value
992                             ), "%s didn't roundtrip" % tag
993
994
995 class xxxxxxxxxxxxxxxxxxxxx(xxxx.xxxxxxxxxxxxx):
996     def xxxxxxx_xxxxxx(xxxx):
997         assert xxxxxxx_xxxx in [
998             x.xxxxx.xxxxxx.xxxxx.xxxxxx,
999             x.xxxxx.xxxxxx.xxxxx.xxxx,
1000         ], (
1001             "xxxxxxxxxxx xxxxxxx xxxx (xxxxxx xxxx) %x xxx xxxxx" % xxxxxxx_xxxx
1002         )
1003
1004
1005 value.__dict__[key] = (
1006     "test"  # set some Thrift field to non-None in the struct aa bb cc dd ee
1007 )
1008
1009 RE_ONE_BACKSLASH = {
1010     "asdf_hjkl_jkl": re.compile(
1011         r"(?<!([0-9]\ ))(?<=(^|\ ))([A-Z]+(\ )?|[0-9](\ )|[a-z](\ )){4,7}([A-Z]|[0-9]|[a-z])($|\b)(?!(\ ?([0-9]\ )|(\.)))"
1012     ),
1013 }
1014
1015 RE_TWO_BACKSLASHES = {
1016     "asdf_hjkl_jkl": re.compile(
1017         r"(?<!([0-9]\ ))(?<=(^|\ ))([A-Z]+(\ )?|[0-9](\ )|[a-z](\\"
1018         r" )){4,7}([A-Z]|[0-9]|[a-z])($|\b)(?!(\ ?([0-9]\ )|(\.)))"
1019     ),
1020 }
1021
1022 RE_THREE_BACKSLASHES = {
1023     "asdf_hjkl_jkl": re.compile(
1024         r"(?<!([0-9]\ ))(?<=(^|\ ))([A-Z]+(\ )?|[0-9](\ )|[a-z](\\\ )){4,7}([A-Z]|[0-9]|[a-z])($|\b)(?!(\ ?([0-9]\ )|(\.)))"
1025     ),
1026 }
1027
1028 # We do NOT split on f-string expressions.
1029 print(
1030     "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam."
1031     f" {[f'{i}' for i in range(10)]}"
1032 )
1033 x = (
1034     "This is a long string which contains an f-expr that should not split"
1035     f" {{{[i for i in range(5)]}}}."
1036 )
1037
1038 # The parens should NOT be removed in this case.
1039 (
1040     "my very long string that should get formatted if I'm careful to make sure it goes"
1041     " over 88 characters which it has now"
1042 )
1043
1044 # The parens should NOT be removed in this case.
1045 (
1046     "my very long string that should get formatted if I'm careful to make sure it goes"
1047     " over 88 characters which it has now"
1048 )
1049
1050 # The parens should NOT be removed in this case.
1051 (
1052     "my very long string"
1053     " that should get formatted"
1054     " if I'm careful to make sure"
1055     " it goes over 88 characters which"
1056     " it has now"
1057 )
1058
1059
1060 def _legacy_listen_examples():
1061     text += (
1062         "    \"listen for the '%(event_name)s' event\"\n"
1063         "\n    # ... (event logic logic logic) ...\n"
1064         % {
1065             "since": since,
1066         }
1067     )
1068
1069
1070 class X:
1071     async def foo(self):
1072         msg = ""
1073         for candidate in CANDIDATES:
1074             msg += (
1075                 "**{candidate.object_type} {candidate.rev}**"
1076                 " - {candidate.description}\n"
1077             )
1078
1079
1080 temp_msg = (
1081     f"{f'{humanize_number(pos)}.': <{pound_len+2}} "
1082     f"{balance: <{bal_len + 5}} "
1083     f"<<{author.display_name}>>\n"
1084 )
1085
1086 assert (
1087     str(suffix_arr)
1088     == "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
1089     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
1090     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
1091 )
1092 assert (
1093     str(suffix_arr)
1094     != "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
1095     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
1096     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
1097 )
1098 assert (
1099     str(suffix_arr)
1100     <= "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
1101     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
1102     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
1103 )
1104 assert (
1105     str(suffix_arr)
1106     >= "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
1107     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
1108     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
1109 )
1110 assert (
1111     str(suffix_arr)
1112     < "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
1113     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
1114     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
1115 )
1116 assert (
1117     str(suffix_arr)
1118     > "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
1119     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
1120     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
1121 )
1122 assert (
1123     str(suffix_arr)
1124     in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$',"
1125     " 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$', 'rykangaroo$',"
1126     " 'ykangaroo$']"
1127 )
1128 assert (
1129     str(suffix_arr)
1130     not in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$',"
1131     " 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$',"
1132     " 'rykangaroo$', 'ykangaroo$']"
1133 )
1134 message = (
1135     f"1. Go to Google Developers Console and log in with your Google account."
1136     f"(https://console.developers.google.com/)"
1137     f"2. You should be prompted to create a new project (name does not matter)."
1138     f"3. Click on Enable APIs and Services at the top."
1139     f"4. In the list of APIs choose or search for YouTube Data API v3 and "
1140     f"click on it. Choose Enable."
1141     f"5. Click on Credentials on the left navigation bar."
1142     f"6. Click on Create Credential at the top."
1143     f'7. At the top click the link for "API key".'
1144     f"8. No application restrictions are needed. Click Create at the bottom."
1145     f"9. You now have a key to add to `{{prefix}}set api youtube api_key`"
1146 )
1147 message = (
1148     f"1. Go to Google Developers Console and log in with your Google account."
1149     f"(https://console.developers.google.com/)"
1150     f"2. You should be prompted to create a new project (name does not matter)."
1151     f"3. Click on Enable APIs and Services at the top."
1152     f"4. In the list of APIs choose or search for YouTube Data API v3 and "
1153     f"click on it. Choose Enable."
1154     f"5. Click on Credentials on the left navigation bar."
1155     f"6. Click on Create Credential at the top."
1156     f'7. At the top click the link for "API key".'
1157     f"8. No application restrictions are needed. Click Create at the bottom."
1158     f"9. You now have a key to add to `{{prefix}}set api youtube api_key`"
1159 )
1160 message = (
1161     "1. Go to Google Developers Console and log in with your Google account."
1162     "(https://console.developers.google.com/)"
1163     "2. You should be prompted to create a new project (name does not matter)."
1164     "3. Click on Enable APIs and Services at the top."
1165     "4. In the list of APIs choose or search for YouTube Data API v3 and "
1166     "click on it. Choose Enable."
1167     "5. Click on Credentials on the left navigation bar."
1168     "6. Click on Create Credential at the top."
1169     '7. At the top click the link for "API key".'
1170     "8. No application restrictions are needed. Click Create at the bottom."
1171     f"9. You now have a key to add to `{prefix}set api youtube api_key`"
1172 )
1173
1174 # It shouldn't matter if the string prefixes are capitalized.
1175 temp_msg = (
1176     f"{F'{humanize_number(pos)}.': <{pound_len+2}} "
1177     f"{balance: <{bal_len + 5}} "
1178     f"<<{author.display_name}>>\n"
1179 )
1180
1181 fstring = f"We have to remember to escape {braces}. Like {{these}}. But not {this}."
1182
1183 welcome_to_programming = R"hello," R" world!"
1184
1185 fstring = (
1186     f"f-strings definitely make things more {difficult} than they need to be for"
1187     " {black}. But boy they sure are handy. The problem is that some lines will need"
1188     f" to have the 'f' whereas others do not. This {line}, for example, needs one."
1189 )
1190
1191 x = (
1192     "This is a long string which contains an f-expr that should not split"
1193     f" {{{[i for i in range(5)]}}}."
1194 )
1195
1196 x = (
1197     "\N{BLACK RIGHT-POINTING TRIANGLE WITH DOUBLE VERTICAL BAR}\N{VARIATION SELECTOR-16}"
1198 )
1199
1200 xxxxxx_xxx_xxxx_xx_xxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxxxx_xxxx_xxxx_xxxxx = xxxx.xxxxxx.xxxxxxxxx.xxxxxxxxxxxxxxxxxxxx(
1201     xx_xxxxxx={
1202         "x3_xxxxxxxx": (
1203             "xxx3_xxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxxxx_xxxxxxxx_xxxxxx_xxxxxxx"
1204         ),
1205     },
1206 )
1207
1208 # Regression test for https://github.com/psf/black/issues/3117.
1209 some_dict = {
1210     "something_something": (
1211         r"Lorem ipsum dolor sit amet, an sed convenire eloquentiam \t"
1212         r"signiferumque, duo ea vocibus consetetur scriptorem. Facer \t"
1213     ),
1214 }
1215
1216 # Regression test for https://github.com/psf/black/issues/3459.
1217 xxxx(
1218     empty_str_as_first_split=(
1219         ""
1220         f"xxxxxxx {xxxxxxxxxx} xxx xxxxxxxxxx xxxxx xxx xxx xx "
1221         "xxxxx xxxxxxxxx xxxxxxx, xxx xxxxxxxxxxx xxx xxxxx. "
1222         f"xxxxxxxxxxxxx xxxx xx xxxxxxxxxx. xxxxx: {x.xxx}"
1223     ),
1224     empty_u_str_as_first_split=(
1225         ""
1226         f"xxxxxxx {xxxxxxxxxx} xxx xxxxxxxxxx xxxxx xxx xxx xx "
1227         "xxxxx xxxxxxxxx xxxxxxx, xxx xxxxxxxxxxx xxx xxxxx. "
1228         f"xxxxxxxxxxxxx xxxx xx xxxxxxxxxx. xxxxx: {x.xxx}"
1229     ),
1230 )
1231
1232 # Regression test for https://github.com/psf/black/issues/3455.
1233 a_dict = {
1234     "/this/is/a/very/very/very/very/very/very/very/very/very/very/long/key/without/spaces":
1235     # And there is a comment before the value
1236     ("item1", "item2", "item3"),
1237 }