Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions tests/eval_files/async102.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,39 @@ async def foo_nested_cs():
# treat __aexit__ as a critical scope
async def __aexit__():
await foo() # error: 4, Statement("__aexit__", lineno-1)


# exclude finally: await x.aclose()
# trio/anyio marks arg-less aclose() as safe
async def foo_aclose_noargs():
# no type tracking in this check, we allow any call that looks like
# `await [...].aclose()`
x = None

try:
...
except BaseException:
await x.aclose()
await x.y.aclose()
finally:
await x.aclose()
await x.y.aclose()


# trio/anyio should still raise errors if there's args
async def foo():
# no type tracking in this check
x = None

try:
...
except BaseException:
await x.aclose(foo) # ASYNC102: 8, Statement("BaseException", lineno-1)
await x.aclose(bar=foo) # ASYNC102: 8, Statement("BaseException", lineno-2)
await x.aclose(*foo) # ASYNC102: 8, Statement("BaseException", lineno-3)
await x.aclose(None) # ASYNC102: 8, Statement("BaseException", lineno-4)
finally:
await x.aclose(foo) # ASYNC102: 8, Statement("try/finally", lineno-8)
await x.aclose(bar=foo) # ASYNC102: 8, Statement("try/finally", lineno-9)
await x.aclose(*foo) # ASYNC102: 8, Statement("try/finally", lineno-10)
await x.aclose(None) # ASYNC102: 8, Statement("try/finally", lineno-11)
28 changes: 0 additions & 28 deletions tests/eval_files/async102_aclose.py

This file was deleted.

26 changes: 0 additions & 26 deletions tests/eval_files/async102_aclose_args.py

This file was deleted.

4 changes: 2 additions & 2 deletions tests/eval_files/async102_anyio.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# type: ignore
# this test will raise the same errors with trio, despite trio.get_cancelled_exc_class not existing
# marked not to run the tests though as error messages will only refer to anyio
# NOTRIO
# ASYNCIO_NO_ERROR # ASYNC102 not applicable to asyncio
# BASE_LIBRARY anyio
# this test will raise the same errors with trio/asyncio, despite [trio|asyncio].get_cancelled_exc_class not existing
# marked not to run the tests though as error messages will only refer to anyio
import anyio
from anyio import get_cancelled_exc_class

Expand Down
49 changes: 0 additions & 49 deletions tests/eval_files/async102_asyncio.py

This file was deleted.

24 changes: 7 additions & 17 deletions tests/eval_files/noqa_no_autofix.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# ARG --enable=ASYNC102
# ASYNCIO_NO_ERROR # ASYNC102 not applicable to asyncio
# ARG --enable=ASYNC109

import trio
from typing import Any
Expand All @@ -9,22 +8,13 @@
async def foo() -> Any: ...


async def foo_no_noqa_102():
try:
pass
finally:
await foo() # ASYNC102: 8, Statement("try/finally", lineno-3)
async def foo_no_noqa_109(timeout): # ASYNC109: 26, "trio"
...


async def foo_noqa_102():
try:
pass
finally:
await foo() # noqa: ASYNC102
async def foo_noqa_102(timeout): # noqa: ASYNC109, "trio"
...


async def foo_bare_noqa_102():
try:
pass
finally:
await foo() # noqa
async def foo_bare_noqa_109(timeout): # noqa, "trio"
...
Loading