forked from python-trio/flake8-async
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoqa.py
69 lines (48 loc) · 1.73 KB
/
noqa.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
# AUTOFIX
# NOANYIO # TODO
# NOASYNCIO
# ARG --enable=ASYNC100,ASYNC911
from typing import Any
import trio
# fmt: off
async def foo_no_noqa():
await trio.lowlevel.checkpoint()
# ASYNC100: 9, 'trio', 'fail_after'
yield # ASYNC911: 8, "yield", Statement("function definition", lineno-2)
await trio.lowlevel.checkpoint()
async def foo_noqa_bare():
with trio.fail_after(5): # noqa
yield # noqa
await trio.lowlevel.checkpoint()
async def foo_noqa_100():
with trio.fail_after(5): # noqa: ASYNC100
await trio.lowlevel.checkpoint()
yield # ASYNC911: 8, "yield", Statement("function definition", lineno-2)
await trio.lowlevel.checkpoint()
async def foo_noqa_911():
# ASYNC100: 9, 'trio', 'fail_after'
yield # noqa: ASYNC911
await trio.lowlevel.checkpoint()
async def foo_noqa_100_911():
with trio.fail_after(5): # noqa: ASYNC100, ASYNC911
yield # noqa: ASYNC911
await trio.lowlevel.checkpoint()
async def foo_noqa_100_911_500():
with trio.fail_after(5): # noqa: ASYNC100, ASYNC911 , ASYNC500,,,
yield # noqa: ASYNC100, ASYNC911 , ASYNC500,,,
await trio.lowlevel.checkpoint()
# fmt: on
# check that noqas work after line numbers have been modified in a different visitor
# this will remove one line
# ASYNC100: 5, 'trio', 'fail_after'
...
async def foo_changed_lineno():
yield # noqa: ASYNC911
await trio.lowlevel.checkpoint()
# this will add two lines
async def foo_changing_lineno(): # ASYNC911: 0, "exit", Statement("yield", lineno+1)
await trio.lowlevel.checkpoint()
yield # ASYNC911: 4, "yield", Statement("function definition", lineno-1)
await trio.lowlevel.checkpoint()
with trio.fail_after(5): # noqa: ASYNC100
...