1 | #!/usr/bin/env python2
|
2 | """
|
3 | Misc
|
4 | """
|
5 | from __future__ import print_function
|
6 |
|
7 | import os
|
8 |
|
9 | from mycpp.mylib import log
|
10 |
|
11 | from typing import List
|
12 |
|
13 |
|
14 | def run_tests():
|
15 | # type: () -> None
|
16 |
|
17 | f = lambda i: i + 1
|
18 |
|
19 | dict_comp = {k: 42 for k in [1, 2, 3]}
|
20 |
|
21 | set_comp = {k for k in [1, 2, 3]}
|
22 |
|
23 | # This is visited as part of list comprehension
|
24 | #gen = (x for x in [1, 2, 3])
|
25 |
|
26 | exec('x = 42')
|
27 |
|
28 | # ok
|
29 | assign_to_listcomp = ['t' for s in xrange(5)]
|
30 |
|
31 | # Not ok
|
32 | mylist = [] # type: List[List[str]]
|
33 | mylist.append(['s' for s in xrange(3)])
|
34 |
|
35 |
|
36 | class A:
|
37 | pass
|
38 |
|
39 |
|
40 | class B:
|
41 | pass
|
42 |
|
43 |
|
44 | class Child(A, B):
|
45 | pass
|
46 |
|
47 |
|
48 | # Doesn't need to be checked, because it fails at runtime
|
49 | #class Child2('invalid'):
|
50 | # pass
|
51 |
|
52 |
|
53 | def run_benchmarks():
|
54 | # type: () -> None
|
55 | raise NotImplementedError()
|
56 |
|
57 |
|
58 | if __name__ == '__main__':
|
59 | if os.getenv('BENCHMARK'):
|
60 | log('Benchmarking...')
|
61 | run_benchmarks()
|
62 | else:
|
63 | run_tests()
|