-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathtest.py
More file actions
143 lines (126 loc) · 2.17 KB
/
test.py
File metadata and controls
143 lines (126 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
@deco1
@deco2()
@deco3.attr1.attr2
class C(Base):
def __init__(self):
pass
@deco4.attr()
def f():
pass
def f(pos0, pos1, *args, **kwargs):
pass
def simple_stmts():
pass
foo() ; del x; pass
if thing:
for a in b:
pass
#Expressions
tmp = (
yield 3,
name,
attr.attrname,
a + b,
3 & 4,
3.0 * 4,
a.b.c.d,
a().b[c],
lambda x: x+1,
p or q and r ^ s,
a < b > c in 5,
{ 1 : y for z in x for y in z},
{ (1, y) for z in x for y in z},
[ y**2 for y in z ],
[],
{},
(),
(1,),
)
foo(1)
foo(a=1)
foo(1,2,*t)
foo(1,a=1,*t)
foo(1,a=1,*t,**d)
f(**d)
def compound_stmts():
if cond:
return x
else:
raise y
while True:
if cond:
break
else:
continue
for x in y:
pass
with a as b, c as d:
body
try:
t1
except:
e1
try:
t2
except Exception:
e2
try:
t3
except Exception as ex:
e3
try:
t4
finally:
f4
try:
t5
except Exception as ex:
e5
finally:
f5
try:
t6
finally:
try:
t7
finally:
f7
#Unusual classdef
class WhyUseParens():
pass
#Annotations
x: 1
x: y
x: {y[a][b]:z-q}
x: f(1, d=3, *t)
#f-strings with format specifier
f'result: {value:0.2f}'
f'result: {value:{width}.{precision}}'
f"Too {'many' if alen > elen else 'few'} parameters for {cls};"
#f" actual {alen}, expected {elen}"
#Backticks
`backticks`
`why, are, we, still, supporting, this in 2019`
def numeric_literals():
# Various corner cases for numeric literals
tmp = (
0b00010101011111111111L,
1_1,
0b1_1,
0x1_1,
0b_010,
0x_010,
0_0,
009.,
009e005,
00123,
0o77777777777L,
0777777777777L,
0o1_1,
0o_010,
1_2_3.4_5_6e7_8_9,
0_0234j
)
#Grammar ambiguity in extractor version 5.4
print(f'{"foo"}')
print(f"{"bar"}")