forked from python-trio/flake8-async
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasync101.py
71 lines (47 loc) · 1.2 KB
/
async101.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
71
# type: ignore
import contextlib
import contextlib as bla
from contextlib import asynccontextmanager, contextmanager, contextmanager as blahabla
import trio
def foo0():
with trio.open_nursery() as _:
yield 1 # error: 8
async def foo1():
async with trio.open_nursery() as _:
yield 1 # error: 8
@contextmanager
def foo2():
with trio.open_nursery() as _:
yield 1 # safe
async def foo3():
async with trio.CancelScope() as _:
yield 1 # error: 8
@asynccontextmanager
async def foo4():
async with trio.open_nursery() as _:
yield 1 # safe
async def foo5():
async with trio.open_nursery():
yield 1 # error: 8
def foo6():
yield 1 # safe
@contextlib.asynccontextmanager
async def foo7():
async with trio.open_nursery() as _:
yield 1 # safe
@bla.contextmanager
def foo8():
with trio.open_nursery() as _:
yield 1 # safe
@blahabla
def foo9():
with trio.open_nursery() as _:
yield 1 # error: 8
@pytest.fixture()
def foo_false_alarm():
with trio.open_nursery() as _:
yield 1
@pytest.fixture
def foo_false_alarm_2():
with trio.open_nursery() as _:
yield 1