forked from python-trio/flake8-async
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasync110.py
70 lines (50 loc) · 1.31 KB
/
async110.py
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
# type: ignore
import trio
import trio as noerror
async def foo():
# only trigger on while loop with body being exactly one sleep[_until] statement
while ...: # error: 4, "trio"
await trio.sleep()
while ...: # error: 4, "trio"
await trio.sleep_until()
# nested
while ...: # safe
while ...: # error: 8, "trio"
await trio.sleep()
await trio.sleep()
while ...: # safe
while ...: # error: 8, "trio"
await trio.sleep()
### the rest are all safe
# don't trigger on bodies with more than one statement
while ...:
await trio.sleep()
await trio.sleep()
while ...: # safe
...
await trio.sleep()
while ...:
await trio.sleep()
await trio.sleep_until()
# check library name
while ...:
await noerror.sleep()
async def sleep(): ...
while ...:
await sleep()
# check function name
while ...:
await trio.sleepies()
# don't trigger on [async] for
for _ in "":
await trio.sleep()
async for _ in trio.blah:
await trio.sleep()
while ...:
async def blah():
await trio.sleep()
while ...:
if ...:
await trio.sleep()
while await trio.sleep():
...