Skip to content

Commit 88d2e1f

Browse files
committed
all tests passing 🎉
1 parent 6193f74 commit 88d2e1f

17 files changed

+29
-28
lines changed

flake8_async/visitors/visitors.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ def visit_With(self, node: ast.With | ast.AsyncWith):
121121
elif get_matching_call(
122122
item.context_expr, "create_task_group", base="anyio"
123123
):
124-
nursery_type = "taskgroup"
124+
nursery_type = "task group"
125125
# check for asyncio.TaskGroup
126126
elif get_matching_call(item.context_expr, "TaskGroup", base="asyncio"):
127-
nursery_type = "taskgroup"
127+
nursery_type = "task group"
128128
start_methods = ("create_task",)
129129
else:
130130
# incorrectly marked as not covered on py39
@@ -213,12 +213,16 @@ def is_nursery_call(node: ast.expr):
213213
):
214214
return False
215215
var = ast.unparse(node.value)
216-
return ("trio" in self.library and var.endswith("nursery")) or (
217-
self.variables.get(var, "")
218-
in (
219-
"trio.Nursery",
220-
"anyio.TaskGroup",
221-
"asyncio.TaskGroup",
216+
return (
217+
("trio" in self.library and var.endswith("nursery"))
218+
or ("anyio" in self.library and var.endswith("task_group"))
219+
or (
220+
self.variables.get(var, "")
221+
in (
222+
"trio.Nursery",
223+
"anyio.TaskGroup",
224+
"asyncio.TaskGroup",
225+
)
222226
)
223227
)
224228

tests/autofix_files/async100_anyio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# AUTOFIX
22
# BASE_LIBRARY anyio
3-
# NOTRIO # trio.create_task_group doesn't exist
43
# ASYNCIO_NO_ERROR
54
import anyio
65

tests/autofix_files/async100_trio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# AUTOFIX
22
# ASYNCIO_NO_ERROR # asyncio.open_nursery doesn't exist
3-
# NOANYIO # anyio.open_nursery doesn't exist
43
import trio
54

65

tests/eval_files/async100_anyio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# AUTOFIX
22
# BASE_LIBRARY anyio
3-
# NOTRIO # trio.create_task_group doesn't exist
43
# ASYNCIO_NO_ERROR
54
import anyio
65

tests/eval_files/async100_trio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# AUTOFIX
22
# ASYNCIO_NO_ERROR # asyncio.open_nursery doesn't exist
3-
# NOANYIO # anyio.open_nursery doesn't exist
43
import trio
54

65

tests/eval_files/async101.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# ARG --no-checkpoint-warning-decorator=no_checkpoint_warning_decorator
33
# ARG --transform-async-generator-decorators=transform_async_gen_decorator
44

5-
# This file contains errors shared between trio and anyio, since they have some
6-
# overlap in naming.
7-
# See async101_xxx which has errors specific to trio/asyncio/anyio.
8-
95

106
import contextlib
117
import contextlib as bla
@@ -149,3 +145,14 @@ def no_checkpoint_warning_deco_fun():
149145
def transfor_async_gen_deco_fun():
150146
with trio.CancelScope():
151147
yield 1 # safe
148+
149+
150+
async def foo_open_nursery():
151+
async with trio.open_nursery() as _:
152+
yield 1 # error: 8
153+
154+
155+
@asynccontextmanager
156+
async def foo_open_nursery_contextmanager():
157+
async with trio.open_nursery() as _:
158+
yield 1 # safe

tests/eval_files/async101_anyio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# BASE_LIBRARY anyio
2-
# TRIO_NO_ERROR
32
# ASYNCIO_NO_ERROR
43

54
import anyio

tests/eval_files/async101_trio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# ASYNCIO_NO_ERROR
2-
# ANYIO_NO_ERROR
32

43
from contextlib import asynccontextmanager
54

tests/eval_files/async111.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# It's possible there's an equivalent asyncio construction/gotcha, but methods are differently named, so this file will not raise any errors
44
# nurseries are named taskgroups in asyncio/anyio
55
# ASYNCIO_NO_ERROR
6-
# ANYIO_NO_ERROR
76
from typing import Any
87

98
import trio

tests/eval_files/async111_anyio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# this only tests anyio.create_task_group in particular
33
# BASE_LIBRARY anyio
44
# ASYNCIO_NO_ERROR
5-
# TRIO_NO_ERROR
65

76

87
import anyio

0 commit comments

Comments
 (0)