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

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