Skip to content

Commit 4146bb4

Browse files
committed
update tests to reflect async102 changes
1 parent b15d632 commit 4146bb4

File tree

6 files changed

+45
-122
lines changed

6 files changed

+45
-122
lines changed

tests/eval_files/async102.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,39 @@ async def foo_nested_cs():
310310
# treat __aexit__ as a critical scope
311311
async def __aexit__():
312312
await foo() # error: 4, Statement("__aexit__", lineno-1)
313+
314+
315+
# exclude finally: await x.aclose()
316+
# trio/anyio marks arg-less aclose() as safe
317+
async def foo_aclose_noargs():
318+
# no type tracking in this check, we allow any call that looks like
319+
# `await [...].aclose()`
320+
x = None
321+
322+
try:
323+
...
324+
except BaseException:
325+
await x.aclose()
326+
await x.y.aclose()
327+
finally:
328+
await x.aclose()
329+
await x.y.aclose()
330+
331+
332+
# trio/anyio should still raise errors if there's args
333+
async def foo():
334+
# no type tracking in this check
335+
x = None
336+
337+
try:
338+
...
339+
except BaseException:
340+
await x.aclose(foo) # ASYNC102: 8, Statement("BaseException", lineno-1)
341+
await x.aclose(bar=foo) # ASYNC102: 8, Statement("BaseException", lineno-2)
342+
await x.aclose(*foo) # ASYNC102: 8, Statement("BaseException", lineno-3)
343+
await x.aclose(None) # ASYNC102: 8, Statement("BaseException", lineno-4)
344+
finally:
345+
await x.aclose(foo) # ASYNC102: 8, Statement("try/finally", lineno-8)
346+
await x.aclose(bar=foo) # ASYNC102: 8, Statement("try/finally", lineno-9)
347+
await x.aclose(*foo) # ASYNC102: 8, Statement("try/finally", lineno-10)
348+
await x.aclose(None) # ASYNC102: 8, Statement("try/finally", lineno-11)

tests/eval_files/async102_aclose.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/eval_files/async102_aclose_args.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/eval_files/async102_anyio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# type: ignore
2+
# this test will raise the same errors with trio, despite trio.get_cancelled_exc_class not existing
3+
# marked not to run the tests though as error messages will only refer to anyio
24
# NOTRIO
35
# ASYNCIO_NO_ERROR # ASYNC102 not applicable to asyncio
46
# BASE_LIBRARY anyio
5-
# this test will raise the same errors with trio/asyncio, despite [trio|asyncio].get_cancelled_exc_class not existing
6-
# marked not to run the tests though as error messages will only refer to anyio
77
import anyio
88
from anyio import get_cancelled_exc_class
99

tests/eval_files/async102_asyncio.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

tests/eval_files/noqa_no_autofix.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# ARG --enable=ASYNC102
2-
# ASYNCIO_NO_ERROR # ASYNC102 not applicable to asyncio
1+
# ARG --enable=ASYNC109
32

43
import trio
54
from typing import Any
@@ -9,22 +8,13 @@
98
async def foo() -> Any: ...
109

1110

12-
async def foo_no_noqa_102():
13-
try:
14-
pass
15-
finally:
16-
await foo() # ASYNC102: 8, Statement("try/finally", lineno-3)
11+
async def foo_no_noqa_109(timeout): # ASYNC109: 26, "trio"
12+
...
1713

1814

19-
async def foo_noqa_102():
20-
try:
21-
pass
22-
finally:
23-
await foo() # noqa: ASYNC102
15+
async def foo_noqa_102(timeout): # noqa: ASYNC109, "trio"
16+
...
2417

2518

26-
async def foo_bare_noqa_102():
27-
try:
28-
pass
29-
finally:
30-
await foo() # noqa
19+
async def foo_bare_noqa_109(timeout): # noqa, "trio"
20+
...

0 commit comments

Comments
 (0)