|
1 | 1 | --- |
2 | 2 | +++ |
3 | | -@@ -45,12 +45,14 @@ |
| 3 | +@@ x,12 x,14 @@ |
4 | 4 |
|
5 | 5 | async def foo1(): # error: 0, "exit", Statement("function definition", lineno) |
6 | 6 | bar() |
|
15 | 15 |
|
16 | 16 |
|
17 | 17 | async def foo_if_2(): |
18 | | -@@ -81,6 +83,7 @@ |
| 18 | +@@ x,6 x,7 @@ |
19 | 19 |
|
20 | 20 | async def foo_ifexp_2(): # error: 0, "exit", Statement("function definition", lineno) |
21 | 21 | print(_ if False and await foo() else await foo()) |
22 | 22 | + await trio.lowlevel.checkpoint() |
23 | 23 |
|
24 | 24 |
|
25 | 25 | # nested function definition |
26 | | -@@ -89,6 +92,7 @@ |
| 26 | +@@ x,6 x,7 @@ |
27 | 27 |
|
28 | 28 | async def foo_func_2(): # error: 4, "exit", Statement("function definition", lineno) |
29 | 29 | bar() |
30 | 30 | + await trio.lowlevel.checkpoint() |
31 | 31 |
|
32 | 32 |
|
33 | 33 | # we don't get a newline after the nested function definition before the checkpoint |
34 | | -@@ -97,17 +101,21 @@ |
| 34 | +@@ x,17 x,21 @@ |
35 | 35 | async def foo_func_3(): # error: 0, "exit", Statement("function definition", lineno) |
36 | 36 | async def foo_func_4(): |
37 | 37 | await foo() |
|
53 | 53 | # fmt: on |
54 | 54 |
|
55 | 55 |
|
56 | | -@@ -144,11 +152,13 @@ |
| 56 | +@@ x,11 x,13 @@ |
57 | 57 | async def foo_condition_2(): # error: 0, "exit", Statement("function definition", lineno) |
58 | 58 | if False and await foo(): |
59 | 59 | ... |
|
67 | 67 |
|
68 | 68 |
|
69 | 69 | async def foo_condition_4(): # safe |
70 | | -@@ -170,6 +180,7 @@ |
| 70 | +@@ x,6 x,7 @@ |
71 | 71 | async def foo_while_1(): # error: 0, "exit", Statement("function definition", lineno) |
72 | 72 | while _: |
73 | 73 | await foo() |
74 | 74 | + await trio.lowlevel.checkpoint() |
75 | 75 |
|
76 | 76 |
|
77 | 77 | async def foo_while_2(): # now safe |
78 | | -@@ -188,12 +199,14 @@ |
| 78 | +@@ x,12 x,14 @@ |
79 | 79 | async def foo_while_4(): # error: 0, "exit", Statement("function definition", lineno) |
80 | 80 | while False: |
81 | 81 | await foo() |
|
90 | 90 |
|
91 | 91 |
|
92 | 92 | async def foo_for_2(): # now safe |
93 | | -@@ -216,6 +229,7 @@ |
| 93 | +@@ x,6 x,7 @@ |
94 | 94 | break |
95 | 95 | else: |
96 | 96 | await foo() |
97 | 97 | + await trio.lowlevel.checkpoint() |
98 | 98 |
|
99 | 99 |
|
100 | 100 | async def foo_while_break_3(): # error: 0, "exit", Statement("function definition", lineno) |
101 | | -@@ -224,6 +238,7 @@ |
| 101 | +@@ x,6 x,7 @@ |
102 | 102 | break |
103 | 103 | else: |
104 | 104 | ... |
105 | 105 | + await trio.lowlevel.checkpoint() |
106 | 106 |
|
107 | 107 |
|
108 | 108 | async def foo_while_break_4(): # error: 0, "exit", Statement("function definition", lineno) |
109 | | -@@ -231,6 +246,7 @@ |
| 109 | +@@ x,6 x,7 @@ |
110 | 110 | break |
111 | 111 | else: |
112 | 112 | ... |
113 | 113 | + await trio.lowlevel.checkpoint() |
114 | 114 |
|
115 | 115 |
|
116 | 116 | async def foo_while_continue_1(): # safe |
117 | | -@@ -254,6 +270,7 @@ |
| 117 | +@@ x,6 x,7 @@ |
118 | 118 | continue |
119 | 119 | else: |
120 | 120 | ... |
121 | 121 | + await trio.lowlevel.checkpoint() |
122 | 122 |
|
123 | 123 |
|
124 | 124 | async def foo_while_continue_4(): # error: 0, "exit", Statement("function definition", lineno) |
125 | | -@@ -261,6 +278,7 @@ |
| 125 | +@@ x,6 x,7 @@ |
126 | 126 | continue |
127 | 127 | else: |
128 | 128 | ... |
129 | 129 | + await trio.lowlevel.checkpoint() |
130 | 130 |
|
131 | 131 |
|
132 | 132 | async def foo_async_for_1(): |
133 | | -@@ -299,6 +317,7 @@ |
| 133 | +@@ x,6 x,7 @@ |
134 | 134 | raise |
135 | 135 | else: |
136 | 136 | await foo() |
137 | 137 | + await trio.lowlevel.checkpoint() |
138 | 138 |
|
139 | 139 |
|
140 | 140 | async def foo_try_2(): # safe |
141 | | -@@ -349,6 +368,7 @@ |
| 141 | +@@ x,6 x,7 @@ |
142 | 142 | pass |
143 | 143 | else: |
144 | 144 | pass |
145 | 145 | + await trio.lowlevel.checkpoint() |
146 | 146 |
|
147 | 147 |
|
148 | 148 | async def foo_try_7(): # safe |
149 | | -@@ -390,6 +410,7 @@ |
| 149 | +@@ x,6 x,7 @@ |
150 | 150 | await trio.sleep(0) |
151 | 151 | except: |
152 | 152 | ... |
153 | 153 | + await trio.lowlevel.checkpoint() |
154 | 154 |
|
155 | 155 |
|
156 | 156 | # safe |
157 | | -@@ -417,16 +438,19 @@ |
| 157 | +@@ x,16 x,19 @@ |
158 | 158 | except: |
159 | 159 | ... |
160 | 160 | finally: |
|
174 | 174 | return # error: 8, "return", Statement("function definition", lineno-2) |
175 | 175 | await foo() |
176 | 176 |
|
177 | | -@@ -435,6 +459,7 @@ |
| 177 | +@@ x,6 x,7 @@ |
178 | 178 | if _: |
179 | 179 | await foo() |
180 | 180 | return # safe |
181 | 181 | + await trio.lowlevel.checkpoint() |
182 | 182 |
|
183 | 183 |
|
184 | 184 | # loop over non-empty static collection |
185 | | -@@ -462,12 +487,14 @@ |
| 185 | +@@ x,12 x,14 @@ |
186 | 186 | async def foo_range_4(): # error: 0, "exit", Statement("function definition", lineno) |
187 | 187 | for i in range(10, 5): |
188 | 188 | await foo() |
|
197 | 197 |
|
198 | 198 |
|
199 | 199 | # https://github.com/Zac-HD/flake8-trio/issues/47 |
200 | | -@@ -551,6 +578,7 @@ |
| 200 | +@@ x,6 x,7 @@ |
201 | 201 | # should error |
202 | 202 | async def foo_comprehension_2(): # error: 0, "exit", Statement("function definition", lineno) |
203 | 203 | [await foo() for x in range(10) if bar()] |
|
0 commit comments