pep8: Move to third_party/.
[samba.git] / third_party / pep8 / testsuite / E12not.py
1 if (
2         x == (
3             3
4         ) or
5         y == 4):
6     pass
7
8 y = x == 2 \
9     or x == 3
10
11 if x == 2 \
12     or y > 1 \
13         or x == 3:
14     pass
15
16 if x == 2 \
17         or y > 1 \
18         or x == 3:
19     pass
20
21
22 if (foo == bar and
23         baz == frop):
24     pass
25
26 if (
27     foo == bar and
28     baz == frop
29 ):
30     pass
31
32
33 a = (
34 )
35
36 a = (123,
37      )
38
39
40 #
41
42
43 if start[1] > end_col and not (
44         over_indent == 4 and indent_next):
45     return(0, "E121 continuation line over-"
46            "indented for visual indent")
47
48
49 print "OK", ("visual",
50              "indent")
51
52 print "Okay", ("visual",
53                "indent_three"
54                )
55
56 print "a-ok", (
57     "there",
58     "dude",
59 )
60
61 print "hello", (
62     "there",
63     "dude")
64
65 print "hello", (
66
67     "there",
68     # "john",
69     "dude")
70
71 print "hello", (
72     "there", "dude")
73
74 print "hello", (
75     "there", "dude",
76 )
77
78 # Aligned with opening delimiter
79 foo = long_function_name(var_one, var_two,
80                          var_three, var_four)
81
82 #
83 # Extra indentation is not necessary.
84 foo = long_function_name(
85     var_one, var_two,
86     var_three, var_four)
87
88
89 arm = 'AAA'    \
90       'BBB'    \
91       'CCC'
92
93 bbb = 'AAA'    \
94       'BBB'    \
95       'CCC'
96
97 cc = ('AAA'
98       'BBB'
99       'CCC')
100
101 cc = {'text': 'AAA'
102               'BBB'
103               'CCC'}
104
105 cc = dict(text='AAA'
106                'BBB')
107
108 sat = 'AAA'    \
109       'BBB'    \
110       'iii'    \
111       'CCC'
112
113 abricot = (3 +
114            4 +
115            5 + 6)
116
117 abricot = 3 + \
118     4 + \
119     5 + 6
120
121 part = [-1, 2, 3,
122         4, 5, 6]
123
124 part = [-1, (2, 3,
125         4, 5, 6), 7,
126         8, 9, 0]
127
128 fnct(1, 2, 3,
129      4, 5, 6)
130
131 fnct(1, 2, 3,
132      4, 5, 6,
133      7, 8, 9,
134      10, 11)
135
136
137 def long_function_name(
138         var_one, var_two, var_three,
139         var_four):
140     print(var_one)
141
142 if ((row < 0 or self.moduleCount <= row or
143      col < 0 or self.moduleCount <= col)):
144     raise Exception("%s,%s - %s" % (row, col, self.moduleCount))
145
146
147 result = {
148     'foo': [
149         'bar', {
150             'baz': 'frop',
151         }
152     ]
153 }
154
155
156 foo = my.func({
157     "foo": "bar",
158 }, "baz")
159
160
161 #
162
163 fooff(aaaa,
164       cca(
165           vvv,
166           dadd
167       ), fff,
168       ggg)
169
170 fooff(aaaa,
171       abbb,
172       cca(
173           vvv,
174           aaa,
175           dadd),
176       "visual indentation is not a multiple of four",)
177 #
178
179 if bar:
180     return(
181         start, 'E121 lines starting with a '
182         'closing bracket should be indented '
183         "to match that of the opening "
184         "bracket's line"
185     )
186 #
187 # you want vertical alignment, so use a parens
188 if ((foo.bar("baz") and
189      foo.bar("frop")
190      )):
191     print "yes"
192
193 # also ok, but starting to look like LISP
194 if ((foo.bar("baz") and
195      foo.bar("frop"))):
196     print "yes"
197
198 if (a == 2 or
199     b == "abc def ghi"
200          "jkl mno"):
201     return True
202
203 if (a == 2 or
204     b == """abc def ghi
205 jkl mno"""):
206     return True
207
208 if length > options.max_line_length:
209     return options.max_line_length, \
210         "E501 line too long (%d characters)" % length
211
212
213 #
214
215
216 print 'l.{line}\t{pos}\t{name}\t{text}'.format(
217     line=token[2][0],
218     pos=pos,
219     name=tokenize.tok_name[token[0]],
220     text=repr(token[1]),
221 )
222
223 print('%-7d %s per second (%d total)' % (
224       options.counters[key] / elapsed, key,
225       options.counters[key]))
226
227
228 if os.path.exists(os.path.join(path, PEP8_BIN)):
229     cmd = ([os.path.join(path, PEP8_BIN)] +
230            self._pep8_options(targetfile))
231
232
233 fixed = (re.sub(r'\t+', ' ', target[c::-1], 1)[::-1] +
234          target[c + 1:])
235
236 fixed = (
237     re.sub(r'\t+', ' ', target[c::-1], 1)[::-1] +
238     target[c + 1:]
239 )
240
241
242 if foo is None and bar is "frop" and \
243         blah == 'yeah':
244     blah = 'yeahnah'
245
246
247 """This is a multi-line
248    docstring."""
249
250
251 if blah:
252     # is this actually readable?  :)
253     multiline_literal = """
254 while True:
255     if True:
256         1
257 """.lstrip()
258     multiline_literal = (
259         """
260 while True:
261     if True:
262         1
263 """.lstrip()
264     )
265     multiline_literal = (
266         """
267 while True:
268     if True:
269         1
270 """
271         .lstrip()
272     )
273
274
275 if blah:
276     multiline_visual = ("""
277 while True:
278     if True:
279         1
280 """
281                         .lstrip())
282
283
284 rv = {'aaa': 42}
285 rv.update(dict.fromkeys((
286     'qualif_nr', 'reasonComment_en', 'reasonComment_fr',
287     'reasonComment_de', 'reasonComment_it'), '?'))
288
289 rv.update(dict.fromkeys(('qualif_nr', 'reasonComment_en',
290                          'reasonComment_fr', 'reasonComment_de',
291                          'reasonComment_it'), '?'))
292
293 rv.update(dict.fromkeys(('qualif_nr', 'reasonComment_en', 'reasonComment_fr',
294           'reasonComment_de', 'reasonComment_it'), '?'))
295
296
297 rv.update(dict.fromkeys(
298     ('qualif_nr', 'reasonComment_en', 'reasonComment_fr',
299      'reasonComment_de', 'reasonComment_it'), '?'
300 ), "foo", context={
301     'alpha': 4, 'beta': 53242234, 'gamma': 17,
302 })
303
304
305 rv.update(
306     dict.fromkeys((
307         'qualif_nr', 'reasonComment_en', 'reasonComment_fr',
308         'reasonComment_de', 'reasonComment_it'), '?'),
309     "foo",
310     context={
311         'alpha': 4, 'beta': 53242234, 'gamma': 17,
312     },
313 )
314
315
316 #
317
318
319 event_obj.write(cursor, user_id, {
320     'user': user,
321     'summary': text,
322     'data': data,
323 })
324
325 event_obj.write(cursor, user_id, {
326     'user': user,
327     'summary': text,
328     'data': {'aaa': 1, 'bbb': 2},
329 })
330
331 event_obj.write(cursor, user_id, {
332     'user': user,
333     'summary': text,
334     'data': {
335         'aaa': 1,
336         'bbb': 2},
337 })
338
339 event_obj.write(cursor, user_id, {
340     'user': user,
341     'summary': text,
342     'data': {'timestamp': now, 'content': {
343         'aaa': 1,
344         'bbb': 2
345     }},
346 })
347
348
349 def qualify_by_address(
350         self, cr, uid, ids, context=None,
351         params_to_check=frozenset(QUALIF_BY_ADDRESS_PARAM)):
352     """ This gets called by the web server """
353
354
355 def qualify_by_address(self, cr, uid, ids, context=None,
356                        params_to_check=frozenset(QUALIF_BY_ADDRESS_PARAM)):
357     """ This gets called by the web server """
358
359
360 _ipv4_re = re.compile('^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.'
361                       '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.'
362                       '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.'
363                       '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$')
364
365
366 fct("""
367     AAA """ + status_2_string)
368
369
370 if context:
371     msg = """\
372 action: GET-CONFIG
373 payload:
374     ip_address: "%(ip)s"
375     username: "%(username)s"
376 """ % context
377
378
379 if context:
380     msg = """\
381 action: \
382 GET-CONFIG
383 """ % context
384
385
386 if context:
387     msg = """\
388 action: """\
389 """GET-CONFIG
390 """ % context
391
392
393 def unicode2html(s):
394     """Convert the characters &<>'" in string s to HTML-safe sequences.
395     Convert newline to <br> too."""
396     return unicode((s or '').replace('&', '&amp;')
397                             .replace('>', '&gt;')
398                             .replace('<', '&lt;')
399                             .replace("'", '&#39;')
400                             .replace('"', '&#34;')
401                             .replace('\n', '<br>\n'))
402
403 #
404 parser.add_option('--count', action='store_true',
405                   help="print total number of errors and warnings "
406                        "to standard error and set exit code to 1 if "
407                        "total is not null")
408
409 parser.add_option('--exclude', metavar='patterns', default=DEFAULT_EXCLUDE,
410                   help="exclude files or directories which match these "
411                        "comma separated patterns (default: %s)" %
412                        DEFAULT_EXCLUDE)
413
414 add_option('--count',
415            help="print total number of errors "
416            "to standard error total is not null")
417
418 add_option('--count',
419            help="print total number of errors "
420                 "to standard error "
421                 "total is not null")
422
423
424 #
425
426
427 help = ("print total number of errors " +
428         "to standard error")
429
430 help = "print total number of errors " \
431        "to standard error"
432
433 help = u"print total number of errors " \
434        u"to standard error"
435
436 help = ur"print total number of errors " \
437        ur"to standard error"
438
439 help = b"print total number of errors " \
440        b"to standard error"
441
442 help = br"print total number of errors " \
443        br"to standard error"
444
445 d = dict('foo', help="exclude files or directories which match these "
446                      "comma separated patterns (default: %s)" %
447                      DEFAULT_EXCLUDE)
448
449 d = dict('foo', help=u"exclude files or directories which match these "
450                      u"comma separated patterns (default: %s)" %
451                      DEFAULT_EXCLUDE)
452
453 d = dict('foo', help=b"exclude files or directories which match these "
454                      b"comma separated patterns (default: %s)" %
455                      DEFAULT_EXCLUDE)
456
457 d = dict('foo', help=br"exclude files or directories which match these "
458                      br"comma separated patterns (default: %s)" %
459                      DEFAULT_EXCLUDE)
460
461 d = dict('foo',
462          help="exclude files or directories which match these "
463               "comma separated patterns (default: %s)" %
464               DEFAULT_EXCLUDE)
465
466 d = dict('foo',
467          help="exclude files or directories which match these "
468               "comma separated patterns (default: %s, %s)" %
469               (DEFAULT_EXCLUDE, DEFAULT_IGNORE)
470          )
471
472 d = dict('foo',
473          help="exclude files or directories which match these "
474               "comma separated patterns (default: %s, %s)" %
475               # who knows what might happen here?
476               (DEFAULT_EXCLUDE, DEFAULT_IGNORE)
477          )
478
479 # parens used to allow the indenting.
480 troublefree_hash = {
481     "hash": "value",
482     "long": ("the quick brown fox jumps over the lazy dog before doing a "
483              "somersault"),
484     "long key that tends to happen more when you're indented": (
485         "stringwithalongtoken you don't want to break"
486     ),
487 }
488
489 # another accepted form
490 troublefree_hash = {
491     "hash": "value",
492     "long": "the quick brown fox jumps over the lazy dog before doing "
493             "a somersault",
494     ("long key that tends to happen more "
495      "when you're indented"): "stringwithalongtoken you don't want to break",
496 }
497 # confusing but accepted... don't do that
498 troublesome_hash = {
499     "hash": "value",
500     "long": "the quick brown fox jumps over the lazy dog before doing a "
501     "somersault",
502     "long key that tends to happen more "
503     "when you're indented": "stringwithalongtoken you don't want to break",
504 }
505
506 #
507 d = dict('foo',
508          help="exclude files or directories which match these "
509               "comma separated patterns (default: %s)" %
510               DEFAULT_EXCLUDE
511          )
512 d = dict('foo',
513          help="exclude files or directories which match these "
514               "comma separated patterns (default: %s)" % DEFAULT_EXCLUDE,
515          foobar="this clearly should work, because it is at "
516                 "the right indent level",
517          )
518
519 rv.update(dict.fromkeys(
520           ('qualif_nr', 'reasonComment_en', 'reasonComment_fr',
521            'reasonComment_de', 'reasonComment_it'),
522           '?'), "foo",
523           context={'alpha': 4, 'beta': 53242234, 'gamma': 17})
524
525
526 def f():
527     try:
528         if not Debug:
529             print('''
530 If you would like to see debugging output,
531 try: %s -d5
532 ''' % sys.argv[0])
533
534
535 d = {  # comment
536     1: 2
537 }
538
539 # issue 138
540 [
541     12,  # this is a multi-line inline
542          # comment
543 ]
544 # issue 151
545 if a > b and \
546    c > d:
547     moo_like_a_cow()
548 #
549 my_list = [
550     1, 2, 3,
551     4, 5, 6,
552 ]
553
554 my_list = [1, 2, 3,
555            4, 5, 6,
556            ]
557
558 result = some_function_that_takes_arguments(
559     'a', 'b', 'c',
560     'd', 'e', 'f',
561 )
562
563 result = some_function_that_takes_arguments('a', 'b', 'c',
564                                             'd', 'e', 'f',
565                                             )
566
567 # issue 203
568 dica = {
569     ('abc'
570      'def'): (
571         'abc'),
572 }
573
574 (abcdef[0]
575        [1]) = (
576     'abc')
577
578 ('abc'
579  'def') == (
580     'abc')
581
582 # issue 214
583 bar(
584     1).zap(
585         2)
586
587 bar(
588     1).zap(
589     2)
590 #
591 if True:
592
593     def example_issue254():
594         return [node.copy(
595             (
596                 replacement
597                 # First, look at all the node's current children.
598                 for child in node.children
599                 # Replace them.
600                 for replacement in replace(child)
601             ),
602             dict(name=token.undefined)
603         )]
604
605
606 def valid_example():
607     return [node.copy(properties=dict(
608             (key, val if val is not None else token.undefined)
609             for key, val in node.items()
610             ))]
611
612
613 def other_example():
614     return [node.copy(properties=dict(
615         (key, val if val is not None else token.undefined)
616         for key, val in node.items()
617     ))]
618
619 foo([
620     'bug'
621 ])
622
623 # issue 144, finally!
624 some_hash = {
625     "long key that tends to happen more when you're indented":
626         "stringwithalongtoken you don't want to break",
627 }
628
629 {
630     1:
631         999999 if True
632         else 0,
633 }
634
635
636 print dedent(
637     '''
638         mkdir -p ./{build}/
639         mv ./build/ ./{build}/%(revision)s/
640     '''.format(
641         build='build',
642         # more stuff
643     )
644 )