]> 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: prefix messages with "Black: " (#3194)
[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
528 # output
529
530
531 class A:
532     def foo():
533         result = type(message)("")
534
535
536 # Don't merge multiline (e.g. triple-quoted) strings.
537 def foo():
538     query = (
539         """SELECT xxxxxxxxxxxxxxxxxxxx(xxx)"""
540         """ FROM xxxxxxxxxxxxxxxx WHERE xxxxxxxxxx AND xxx <> xxxxxxxxxxxxxx()"""
541     )
542
543
544 # There was a bug where tuples were being identified as long strings.
545 long_tuple = (
546     "Apple",
547     "Berry",
548     "Cherry",
549     "Dill",
550     "Evergreen",
551     "Fig",
552     "Grape",
553     "Harry",
554     "Iglu",
555     "Jaguar",
556 )
557
558 stupid_format_method_bug = (
559     "Some really long string that just so happens to be the {} {} to force the 'format'"
560     " method to hang over the line length boundary. This is pretty annoying.".format(
561         "perfect", "length"
562     )
563 )
564
565
566 class A:
567     def foo():
568         os.system(
569             "This is a regression test. xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx"
570             " xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx"
571             " xxxx.".format("xxxxxxxxxx", "xxxxxx", "xxxxxxxxxx")
572         )
573
574
575 class A:
576     def foo():
577         XXXXXXXXXXXX.append(
578             (
579                 "xxx_xxxxxxxxxx(xxxxx={}, xxxx={}, xxxxx, xxxx_xxxx_xxxxxxxxxx={})"
580                 .format(xxxxx, xxxx, xxxx_xxxx_xxxxxxxxxx),
581                 my_var,
582                 my_other_var,
583             )
584         )
585
586
587 class A:
588     class B:
589         def foo():
590             bar(
591                 "[{}]: xxx_xxxxxxxxxx(xxxxx={}, xxxx={}, xxxxx={}"
592                 " xxxx_xxxx_xxxxxxxxxx={}, xxxx={})".format(
593                     xxxx._xxxxxxxxxxxxxx, xxxxx, xxxx, xxxx_xxxx_xxxxxxxxxx, xxxxxxx
594                 ),
595                 varX,
596                 varY,
597                 varZ,
598             )
599
600
601 def foo(xxxx):
602     for xxx_xxxx, _xxx_xxx, _xxx_xxxxx, xxx_xxxx in xxxx:
603         for xxx in xxx_xxxx:
604             assert ("x" in xxx) or (xxx in xxx_xxx_xxxxx), (
605                 "{0} xxxxxxx xx {1}, xxx {1} xx xxx xx xxxx xx xxx xxxx: xxx xxxx {2}"
606                 .format(xxx_xxxx, xxx, xxxxxx.xxxxxxx(xxx_xxx_xxxxx))
607             )
608
609
610 class A:
611     def disappearing_comment():
612         return (
613             (  # xx -x xxxxxxx xx xxx xxxxxxx.
614                 "{{xxx_xxxxxxxxxx_xxxxxxxx}} xxx xxxx {} {{xxxx}} >&2".format(
615                     "{xxxx} {xxxxxx}"
616                     if xxxxx.xx_xxxxxxxxxx
617                     else (  # Disappearing Comment
618                         "--xxxxxxx --xxxxxx=x --xxxxxx-xxxxx=xxxxxx"
619                         " --xxxxxx-xxxx=xxxxxxxxxxx.xxx"
620                     )
621                 )
622             ),
623             (x, y, z),
624         )
625
626
627 class A:
628     class B:
629         def foo():
630             xxxxx_xxxx(
631                 xx,
632                 "\t"
633                 "@xxxxxx '{xxxx_xxx}\t' > {xxxxxx_xxxx}.xxxxxxx;"
634                 "{xxxx_xxx} >> {xxxxxx_xxxx}.xxxxxxx 2>&1; xx=$$?;"
635                 "xxxx $$xx".format(
636                     xxxx_xxx=xxxx_xxxxxxx,
637                     xxxxxx_xxxx=xxxxxxx + "/" + xxxx_xxx_xxxx,
638                     x=xxx_xxxxx_xxxxx_xxx,
639                 ),
640                 x,
641                 y,
642                 z,
643             )
644
645
646 func_call_where_string_arg_has_method_call_and_bad_parens(
647     "A long string with {}. This string is so long that it is ridiculous. It can't fit"
648     " on one line at alllll.".format("formatting"),
649 )
650
651 func_call_where_string_arg_has_old_fmt_and_bad_parens(
652     "A long string with {}. This string is so long that it is ridiculous. It can't fit"
653     " on one line at alllll." % "formatting",
654 )
655
656 func_call_where_string_arg_has_old_fmt_and_bad_parens(
657     "A long string with {}. This {} is so long that it is ridiculous. It can't fit on"
658     " one line at alllll." % ("formatting", "string"),
659 )
660
661
662 class A:
663     def append(self):
664         if True:
665             xxxx.xxxxxxx.xxxxx(
666                 "xxxxxxxxxx xxxx xx xxxxxx(%x) xx %x xxxx xx xxx %x.xx"
667                 % (len(self) + 1, xxxx.xxxxxxxxxx, xxxx.xxxxxxxxxx)
668                 + " %.3f (%s) to %.3f (%s).\n"
669                 % (
670                     xxxx.xxxxxxxxx,
671                     xxxx.xxxxxxxxxxxxxx(xxxx.xxxxxxxxx),
672                     x,
673                     xxxx.xxxxxxxxxxxxxx(xx),
674                 )
675             )
676
677
678 class A:
679     def foo():
680         some_func_call(
681             "xxxxxxxxxx",
682             "xx {xxxxxxxxxxx}/xxxxxxxxxxx.xxx xxxx.xxx && xxxxxx -x "
683             '"xxxx xxxxxxx xxxxxx xxxx; xxxx xxxxxx_xxxxx xxxxxx xxxx; '
684             "xxxx.xxxx_xxxxxx(['xxxx.xxx'], xxxx.xxxxxxx().xxxxxxxxxx)\" ",
685             None,
686             ("xxxxxxxxxxx",),
687         ),
688
689
690 class A:
691     def foo():
692         some_func_call(
693             "xx {xxxxxxxxxxx}/xxxxxxxxxxx.xxx xxxx.xxx && xxxxxx -x "
694             "xxxx, ('xxxxxxx xxxxxx xxxx, xxxx') xxxxxx_xxxxx xxxxxx xxxx; "
695             "xxxx.xxxx_xxxxxx(['xxxx.xxx'], xxxx.xxxxxxx().xxxxxxxxxx)\" ",
696             None,
697             ("xxxxxxxxxxx",),
698         ),
699
700
701 xxxxxxx = {
702     "xx": (
703         "xxxx xxxxxxx xxxxxxxxx -x xxx -x /xxx/{0} -x xxx,xxx -xx {1} -xx {1} -xx"
704         " xxx=xxx_xxxx,xxx_xx,xxx_xxx,xxx_xxxx,xxx_xx,xxx_xxx | xxxxxx -x xxxxxxxx -x"
705         " xxxxxxxx -x"
706     ),
707     "xx": (
708         "xxxx xxxxxxx xxxxxxxxx -x xxx -x /xxx/{0} -x xxx,xxx -xx {1} -xx {1} -xx"
709         " xxx=xxx_xxxx_xxx_xxxx,xxx_xx_xxx_xxxx,xxx_xxxx_xxx_xxxx,xxx_xx_xxxx_xxxx,xxx_xxx_xxxx,xxx_xxx_xxxx"
710         " xxxx=xxx | xxxxxx -x xxxxxxxx -x xxxxxxxx -x"
711     ),
712 }
713
714
715 class A:
716     def foo(self):
717         if True:
718             xxxxx_xxxxxxxxxxxx(
719                 "xxx xxxxxx xxx xxxxxxxxx.xx xx xxxxxxxx.  xxx xxxxxxxxxxxxx.xx"
720                 " xxxxxxx "
721                 + "xx xxxxxx xxxxxx xxxxxx xx xxxxxxx xxx xxx ${0} xx x xxxxxxxx xxxxx"
722                 .xxxxxx(xxxxxx_xxxxxx_xxx)
723             )
724
725
726 class A:
727     class B:
728         def foo():
729             row = {
730                 "xxxxxxxxxxxxxxx": xxxxxx_xxxxx_xxxx,
731                 # 'xxxxxxxxxxxxxxxxxxxxxxx'
732                 # 'xxxxxxxxxxxxxxxxxxxxxx'
733                 # 'xxxxxxxxxxxxxxxxxx'
734                 # 'xxxxxxxxxxxxxxxxx'
735                 "xxxxxxxxxx": xxxxx_xxxxx,
736             }
737
738
739 class A:
740     def xxxx_xxx_xx_xxxxxxxxxx_xxxx_xxxxxxxxx(xxxx):
741         xxxxxxxx = [
742             xxxxxxxxxxxxxxxx(
743                 "xxxx",
744                 xxxxxxxxxxx={
745                     "xxxx": 1.0,
746                 },
747                 xxxxxx={"xxxxxx 1": xxxxxx(xxxx="xxxxxx 1", xxxxxx=600.0)},
748                 xxxxxxxx_xxxxxxx=0.0,
749             ),
750             xxxxxxxxxxxxxxxx(
751                 "xxxxxxx",
752                 xxxxxxxxxxx={
753                     "xxxx": 1.0,
754                 },
755                 xxxxxx={"xxxxxx 1": xxxxxx(xxxx="xxxxxx 1", xxxxxx=200.0)},
756                 xxxxxxxx_xxxxxxx=0.0,
757             ),
758             xxxxxxxxxxxxxxxx(
759                 "xxxx",
760             ),
761         ]
762
763
764 some_dictionary = {
765     "xxxxx006": [
766         "xxx-xxx"
767         " xxxxx3xxxx1xx2xxxxxxxxxxxxxx0xx6xxxxxxxxxx2xxxxxx9xxxxxxxxxx0xxxxx1xxx2x/xx9xx6+x+xxxxxxxxxxxxxx4xxxxxxxxxxxxxxxxxxxxx43xxx2xx2x4x++xxx6xxxxxxxxx+xxxxx/xx9x+xxxxxxxxxxxxxx8x15xxxxxxxxxxxxxxxxx82xx/xxxxxxxxxxxxxx/x5xxxxxxxxxxxxxx6xxxxxx74x4/xxx4x+xxxxxxxxx2xxxxxxxx87xxxxx4xxxxxxxx3xx0xxxxx4xxx1xx9xx5xxxxxxx/xxxxx5xx6xx4xxxx1x/x2xxxxxxxxxxxx64xxxxxxx1x0xx5xxxxxxxxxxxxxx=="
768         " xxxxx000 xxxxxxxxxx\n",
769         "xxx-xxx"
770         " xxxxx3xxxx1xx2xxxxxxxxxxxxxx6xxxxxxxxxxxxxx9xxxxxxxxxxxxx3xxx9xxxxxxxxxxxxxxxx0xxxxxxxxxxxxxxxxx2xxxx2xxx6xxxxx/xx54xxxxxxxxx4xxx3xxxxxx9xx3xxxxx39xxxxxxxxx5xx91xxxx7xxxxxx8xxxxxxxxxxxxxxxx9xxx93xxxxxxxxxxxxxxxxx7xxx8xx8xx4/x1xxxxx1x3xxxxxxxxxxxxx3xxxxxx9xx4xx4x7xxxxxxxxxxxxx1xxxxxxxxx7xxxxxxxxxxxxxx4xx6xxxxxxxxx9xxx7xxxx2xxxxxxxxxxxxxxxxxxxxxx8xxxxxxxxxxxxxxxxxxxx6xx=="
771         " xxxxx010 xxxxxxxxxx\n",
772     ],
773     "xxxxx016": [
774         "xxx-xxx"
775         " xxxxx3xxxx1xx2xxxxxxxxxxxxxx0xx6xxxxxxxxxx2xxxxxx9xxxxxxxxxx0xxxxx1xxx2x/xx9xx6+x+xxxxxxxxxxxxxx4xxxxxxxxxxxxxxxxxxxxx43xxx2xx2x4x++xxx6xxxxxxxxx+xxxxx/xx9x+xxxxxxxxxxxxxx8x15xxxxxxxxxxxxxxxxx82xx/xxxxxxxxxxxxxx/x5xxxxxxxxxxxxxx6xxxxxx74x4/xxx4x+xxxxxxxxx2xxxxxxxx87xxxxx4xxxxxxxx3xx0xxxxx4xxx1xx9xx5xxxxxxx/xxxxx5xx6xx4xxxx1x/x2xxxxxxxxxxxx64xxxxxxx1x0xx5xxxxxxxxxxxxxx=="
776         " xxxxx000 xxxxxxxxxx\n",
777         "xxx-xxx"
778         " xxxxx3xxxx1xx2xxxxxxxxxxxxxx6xxxxxxxxxxxxxx9xxxxxxxxxxxxx3xxx9xxxxxxxxxxxxxxxx0xxxxxxxxxxxxxxxxx2xxxx2xxx6xxxxx/xx54xxxxxxxxx4xxx3xxxxxx9xx3xxxxx39xxxxxxxxx5xx91xxxx7xxxxxx8xxxxxxxxxxxxxxxx9xxx93xxxxxxxxxxxxxxxxx7xxx8xx8xx4/x1xxxxx1x3xxxxxxxxxxxxx3xxxxxx9xx4xx4x7xxxxxxxxxxxxx1xxxxxxxxx7xxxxxxxxxxxxxx4xx6xxxxxxxxx9xxx7xxxx2xxxxxxxxxxxxxxxxxxxxxx8xxxxxxxxxxxxxxxxxxxx6xx=="
779         " xxxxx010 xxxxxxxxxx\n",
780     ],
781 }
782
783
784 def foo():
785     xxx_xxx = (  # xxxx xxxxxxxxxx xxxx xx xxxx xx xxx xxxxxxxx xxxxxx xxxxx.
786         'xxxx xxx xxxxxxxx_xxxx xx "xxxxxxxxxx".\n xxx: xxxxxx xxxxxxxx_xxxx=xxxxxxxxxx'
787     )
788
789
790 some_tuple = ("some string", "some string which should be joined")
791
792 some_commented_string = (  # This comment gets thrown to the top.
793     "This string is long but not so long that it needs hahahah toooooo be so greatttt"
794     " {} that I just can't think of any more good words to say about it at"
795     " allllllllllll".format("ha")  # comments here are fine
796 )
797
798 some_commented_string = (
799     "This string is long but not so long that it needs hahahah toooooo be so greatttt"  # But these
800     " {} that I just can't think of any more good words to say about it at"  # comments will stay
801     " allllllllllll".format("ha")  # comments here are fine
802 )
803
804 lpar_and_rpar_have_comments = func_call(  # LPAR Comment
805     "Long really ridiculous type of string that shouldn't really even exist at all. I"
806     " mean commmme onnn!!!",  # Comma Comment
807 )  # RPAR Comment
808
809 cmd_fstring = (
810     "sudo -E deluge-console info --detailed --sort-reverse=time_added "
811     f"{'' if ID is None else ID} | perl -nE 'print if /^{field}:/'"
812 )
813
814 cmd_fstring = (
815     "sudo -E deluge-console info --detailed --sort-reverse=time_added"
816     f" {'' if ID is None else ID} | perl -nE 'print if /^{field}:/'"
817 )
818
819 cmd_fstring = (
820     "sudo -E deluge-console info --detailed --sort-reverse=time_added"
821     f" {'{{}}' if ID is None else ID} | perl -nE 'print if /^{field}:/'"
822 )
823
824 cmd_fstring = (
825     "sudo -E deluge-console info --detailed --sort-reverse=time_added {'' if ID is"
826     f" None else ID}} | perl -nE 'print if /^{field}:/'"
827 )
828
829 fstring = (
830     "This string really doesn't need to be an {{fstring}}, but this one most"
831     f" certainly, absolutely {does}."
832 )
833
834 fstring = f"We have to remember to escape {braces}. Like {{these}}. But not {this}."
835
836
837 class A:
838     class B:
839         def foo():
840             st_error = STError(
841                 f"This string ({string_leaf.value}) appears to be pointless (i.e. has"
842                 " no parent)."
843             )
844
845
846 def foo():
847     user_regex = _lazy_re_compile(
848         r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*\Z"  # dot-atom
849         r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"\Z)',  # quoted-string
850         re.IGNORECASE,
851     )
852
853
854 def foo():
855     user_regex = _lazy_re_compile(
856         "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"  # dot-atom
857         "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",  # quoted-string
858         xyz,
859     )
860
861
862 def foo():
863     user_regex = _lazy_re_compile(
864         "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"  # dot-atom
865         "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",  # quoted-string
866         xyz,
867     )
868
869
870 class A:
871     class B:
872         def foo():
873             if not hasattr(module, name):
874                 raise ValueError(
875                     "Could not find object %s in %s.\n"
876                     "Please note that you cannot serialize things like inner "
877                     "classes. Please move the object into the main module "
878                     "body to use migrations.\n"
879                     "For more information, see "
880                     "https://docs.djangoproject.com/en/%s/topics/migrations/#serializing-values"
881                     % (name, module_name, get_docs_version())
882                 )
883
884
885 class A:
886     class B:
887         def foo():
888             if not hasattr(module, name):
889                 raise ValueError(
890                     "Could not find object %s in %s.\nPlease note that you cannot"
891                     " serialize things like inner classes. Please move the object into"
892                     " the main module body to use migrations.\nFor more information,"
893                     " see https://docs.djangoproject.com/en/%s/topics/migrations/#serializing-values"
894                     % (name, module_name, get_docs_version())
895                 )
896
897
898 x = (
899     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
900     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
901     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
902     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
903 )
904
905
906 class Step(StepBase):
907     def who(self):
908         self.cmd = (
909             "SR AAAA-CORRECT NAME IS {last_name} {first_name}{middle_name}"
910             " {title}/P{passenger_association}".format(
911                 last_name=last_name,
912                 first_name=first_name,
913                 middle_name=middle_name,
914                 title=title,
915                 passenger_association=passenger_association,
916             )
917         )
918
919
920 xxxxxxx_xxxxxx_xxxxxxx = xxx(
921     [
922         xxxxxxxxxxxx(
923             xxxxxx_xxxxxxx=(
924                 '((x.aaaaaaaaa = "xxxxxx.xxxxxxxxxxxxxxxxxxxxx") || (x.xxxxxxxxx ='
925                 ' "xxxxxxxxxxxx")) && '
926                 # xxxxx xxxxxxxxxxxx xxxx xxx (xxxxxxxxxxxxxxxx) xx x xxxxxxxxx xx xxxxxx.
927                 "(x.bbbbbbbbbbbb.xxx != "
928                 '"xxx:xxx:xxx::cccccccccccc:xxxxxxx-xxxx/xxxxxxxxxxx/xxxxxxxxxxxxxxxxx") && '
929             )
930         )
931     ]
932 )
933
934 if __name__ == "__main__":
935     for i in range(4, 8):
936         cmd = (
937             r"for pid in $(ps aux | grep paster | grep -v grep | grep '\-%d' | awk"
938             r" '{print $2}'); do kill $pid; done" % (i)
939         )
940
941
942 def A():
943     def B():
944         def C():
945             def D():
946                 def E():
947                     def F():
948                         def G():
949                             assert (
950                                 c_float(val[0][0] / val[0][1]).value
951                                 == c_float(value[0][0] / value[0][1]).value
952                             ), "%s didn't roundtrip" % tag
953
954
955 class xxxxxxxxxxxxxxxxxxxxx(xxxx.xxxxxxxxxxxxx):
956     def xxxxxxx_xxxxxx(xxxx):
957         assert xxxxxxx_xxxx in [
958             x.xxxxx.xxxxxx.xxxxx.xxxxxx,
959             x.xxxxx.xxxxxx.xxxxx.xxxx,
960         ], (
961             "xxxxxxxxxxx xxxxxxx xxxx (xxxxxx xxxx) %x xxx xxxxx" % xxxxxxx_xxxx
962         )
963
964
965 value.__dict__[
966     key
967 ] = "test"  # set some Thrift field to non-None in the struct aa bb cc dd ee
968
969 RE_ONE_BACKSLASH = {
970     "asdf_hjkl_jkl": re.compile(
971         r"(?<!([0-9]\ ))(?<=(^|\ ))([A-Z]+(\ )?|[0-9](\ )|[a-z](\ )){4,7}([A-Z]|[0-9]|[a-z])($|\b)(?!(\ ?([0-9]\ )|(\.)))"
972     ),
973 }
974
975 RE_TWO_BACKSLASHES = {
976     "asdf_hjkl_jkl": re.compile(
977         r"(?<!([0-9]\ ))(?<=(^|\ ))([A-Z]+(\ )?|[0-9](\ )|[a-z](\\"
978         r" )){4,7}([A-Z]|[0-9]|[a-z])($|\b)(?!(\ ?([0-9]\ )|(\.)))"
979     ),
980 }
981
982 RE_THREE_BACKSLASHES = {
983     "asdf_hjkl_jkl": re.compile(
984         r"(?<!([0-9]\ ))(?<=(^|\ ))([A-Z]+(\ )?|[0-9](\ )|[a-z](\\\ )){4,7}([A-Z]|[0-9]|[a-z])($|\b)(?!(\ ?([0-9]\ )|(\.)))"
985     ),
986 }
987
988 # We do NOT split on f-string expressions.
989 print(
990     "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam."
991     f" {[f'{i}' for i in range(10)]}"
992 )
993 x = (
994     "This is a long string which contains an f-expr that should not split"
995     f" {{{[i for i in range(5)]}}}."
996 )
997
998 # The parens should NOT be removed in this case.
999 (
1000     "my very long string that should get formatted if I'm careful to make sure it goes"
1001     " over 88 characters which it has now"
1002 )
1003
1004 # The parens should NOT be removed in this case.
1005 (
1006     "my very long string that should get formatted if I'm careful to make sure it goes"
1007     " over 88 characters which it has now"
1008 )
1009
1010 # The parens should NOT be removed in this case.
1011 (
1012     "my very long string"
1013     " that should get formatted"
1014     " if I'm careful to make sure"
1015     " it goes over 88 characters which"
1016     " it has now"
1017 )
1018
1019
1020 def _legacy_listen_examples():
1021     text += (
1022         "    \"listen for the '%(event_name)s' event\"\n"
1023         "\n    # ... (event logic logic logic) ...\n"
1024         % {
1025             "since": since,
1026         }
1027     )
1028
1029
1030 class X:
1031     async def foo(self):
1032         msg = ""
1033         for candidate in CANDIDATES:
1034             msg += (
1035                 "**{candidate.object_type} {candidate.rev}**"
1036                 " - {candidate.description}\n"
1037             )
1038
1039
1040 temp_msg = (
1041     f"{f'{humanize_number(pos)}.': <{pound_len+2}} "
1042     f"{balance: <{bal_len + 5}} "
1043     f"<<{author.display_name}>>\n"
1044 )
1045
1046 assert (
1047     str(suffix_arr)
1048     == "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
1049     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
1050     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
1051 )
1052 assert (
1053     str(suffix_arr)
1054     != "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
1055     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
1056     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
1057 )
1058 assert (
1059     str(suffix_arr)
1060     <= "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
1061     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
1062     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
1063 )
1064 assert (
1065     str(suffix_arr)
1066     >= "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
1067     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
1068     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
1069 )
1070 assert (
1071     str(suffix_arr)
1072     < "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
1073     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
1074     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
1075 )
1076 assert (
1077     str(suffix_arr)
1078     > "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
1079     "'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
1080     "'o$', 'oo$', 'roo$', 'rykangaroo$', 'ykangaroo$']"
1081 )
1082 assert (
1083     str(suffix_arr)
1084     in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$',"
1085     " 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$', 'rykangaroo$',"
1086     " 'ykangaroo$']"
1087 )
1088 assert (
1089     str(suffix_arr)
1090     not in "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', 'grykangaroo$',"
1091     " 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', 'o$', 'oo$', 'roo$',"
1092     " 'rykangaroo$', 'ykangaroo$']"
1093 )
1094 message = (
1095     f"1. Go to Google Developers Console and log in with your Google account."
1096     f"(https://console.developers.google.com/)"
1097     f"2. You should be prompted to create a new project (name does not matter)."
1098     f"3. Click on Enable APIs and Services at the top."
1099     f"4. In the list of APIs choose or search for YouTube Data API v3 and "
1100     f"click on it. Choose Enable."
1101     f"5. Click on Credentials on the left navigation bar."
1102     f"6. Click on Create Credential at the top."
1103     f'7. At the top click the link for "API key".'
1104     f"8. No application restrictions are needed. Click Create at the bottom."
1105     f"9. You now have a key to add to `{{prefix}}set api youtube api_key`"
1106 )
1107 message = (
1108     f"1. Go to Google Developers Console and log in with your Google account."
1109     f"(https://console.developers.google.com/)"
1110     f"2. You should be prompted to create a new project (name does not matter)."
1111     f"3. Click on Enable APIs and Services at the top."
1112     f"4. In the list of APIs choose or search for YouTube Data API v3 and "
1113     f"click on it. Choose Enable."
1114     f"5. Click on Credentials on the left navigation bar."
1115     f"6. Click on Create Credential at the top."
1116     f'7. At the top click the link for "API key".'
1117     f"8. No application restrictions are needed. Click Create at the bottom."
1118     f"9. You now have a key to add to `{{prefix}}set api youtube api_key`"
1119 )
1120 message = (
1121     "1. Go to Google Developers Console and log in with your Google account."
1122     "(https://console.developers.google.com/)"
1123     "2. You should be prompted to create a new project (name does not matter)."
1124     "3. Click on Enable APIs and Services at the top."
1125     "4. In the list of APIs choose or search for YouTube Data API v3 and "
1126     "click on it. Choose Enable."
1127     "5. Click on Credentials on the left navigation bar."
1128     "6. Click on Create Credential at the top."
1129     '7. At the top click the link for "API key".'
1130     "8. No application restrictions are needed. Click Create at the bottom."
1131     f"9. You now have a key to add to `{prefix}set api youtube api_key`"
1132 )
1133
1134 # It shouldn't matter if the string prefixes are capitalized.
1135 temp_msg = (
1136     f"{F'{humanize_number(pos)}.': <{pound_len+2}} "
1137     f"{balance: <{bal_len + 5}} "
1138     f"<<{author.display_name}>>\n"
1139 )
1140
1141 fstring = f"We have to remember to escape {braces}. Like {{these}}. But not {this}."
1142
1143 welcome_to_programming = R"hello," R" world!"
1144
1145 fstring = (
1146     f"f-strings definitely make things more {difficult} than they need to be for"
1147     " {black}. But boy they sure are handy. The problem is that some lines will need"
1148     f" to have the 'f' whereas others do not. This {line}, for example, needs one."
1149 )
1150
1151 x = (
1152     "This is a long string which contains an f-expr that should not split"
1153     f" {{{[i for i in range(5)]}}}."
1154 )
1155
1156 x = (
1157     "\N{BLACK RIGHT-POINTING TRIANGLE WITH DOUBLE VERTICAL BAR}\N{VARIATION SELECTOR-16}"
1158 )
1159
1160 xxxxxx_xxx_xxxx_xx_xxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxxxx_xxxx_xxxx_xxxxx = xxxx.xxxxxx.xxxxxxxxx.xxxxxxxxxxxxxxxxxxxx(
1161     xx_xxxxxx={
1162         "x3_xxxxxxxx": (
1163             "xxx3_xxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxxxx_xxxxxxxx_xxxxxx_xxxxxxx"
1164         ),
1165     },
1166 )