-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update error descriptions in README to better reflect which errors wo…
…rk with which library, and minor updates. 102/103/104 now sees asyncio.exceptions.CancelledError as a critical exception. Fix import/arg detection of asyncio. add asyncio102_asyncio. add async103_all_imported. Finally make test_anyio_from_config autodetect the correct line number. Fix BASE_LIBRARY marker being interpreted as a bool. Make #NOTRIO/#NOASYNCIO/#NOANYIO run the visitor but ignore the result, instead of skipping, to check it doesn't crash. Generalize error-message-library-check.
- Loading branch information
Showing
13 changed files
with
270 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# type: ignore | ||
# NOANYIO | ||
# NOTRIO | ||
# BASE_LIBRARY asyncio | ||
from contextlib import asynccontextmanager | ||
|
||
import asyncio | ||
|
||
|
||
async def foo(): | ||
# asyncio.move_on_after does not exist, so this will raise an error | ||
try: | ||
... | ||
finally: | ||
with asyncio.move_on_after(deadline=30) as s: | ||
s.shield = True | ||
await foo() # error: 12, Statement("try/finally", lineno-5) | ||
|
||
try: | ||
pass | ||
finally: | ||
await foo() # error: 8, Statement("try/finally", lineno-3) | ||
|
||
# asyncio.CancelScope does not exist, so this will raise an error | ||
try: | ||
pass | ||
finally: | ||
with asyncio.CancelScope(deadline=30, shield=True): | ||
await foo() # error: 12, Statement("try/finally", lineno-4) | ||
|
||
# TODO: I think this is the asyncio-equivalent, but functionality to ignore the error | ||
# has not been implemented | ||
|
||
try: | ||
... | ||
finally: | ||
await asyncio.shield( # error: 8, Statement("try/finally", lineno-3) | ||
asyncio.wait_for(foo()) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# NOASYNCIO | ||
# NOANYIO - don't run it with substitutions | ||
import anyio | ||
import trio | ||
import asyncio | ||
from asyncio.exceptions import CancelledError | ||
from asyncio import exceptions | ||
|
||
try: | ||
... | ||
except trio.Cancelled: # ASYNC103: 7, "trio.Cancelled" | ||
... | ||
except ( | ||
anyio.get_cancelled_exc_class() # ASYNC103: 4, "anyio.get_cancelled_exc_class()" | ||
): | ||
... | ||
except CancelledError: # ASYNC103: 7, "CancelledError" | ||
... | ||
except: # safe | ||
... | ||
|
||
# reordered | ||
try: | ||
... | ||
except ( | ||
asyncio.exceptions.CancelledError # ASYNC103: 4, "asyncio.exceptions.CancelledError" | ||
): | ||
... | ||
except ( | ||
anyio.get_cancelled_exc_class() # ASYNC103: 4, "anyio.get_cancelled_exc_class()" | ||
): | ||
... | ||
except trio.Cancelled: # ASYNC103: 7, "trio.Cancelled" | ||
... | ||
except: # safe | ||
... | ||
|
||
# asyncio supports all three ways of importing asyncio.exceptions.CancelledError | ||
try: | ||
... | ||
except exceptions.CancelledError: # ASYNC103: 7, "exceptions.CancelledError" | ||
... | ||
|
||
# catching any one of the exceptions in multi-library files will suppress errors on the bare except. It's unlikely a try block contains code that can raise multiple ones. | ||
try: | ||
... | ||
except ( | ||
anyio.get_cancelled_exc_class() # ASYNC103: 4, "anyio.get_cancelled_exc_class()" | ||
): | ||
... | ||
except: # safe ? | ||
... | ||
|
||
try: | ||
... | ||
except trio.Cancelled: # ASYNC103: 7, "trio.Cancelled" | ||
... | ||
except: # safe ? | ||
... | ||
|
||
try: | ||
... | ||
except ( | ||
asyncio.exceptions.CancelledError # ASYNC103: 4, "asyncio.exceptions.CancelledError" | ||
): | ||
... | ||
except: # safe ? | ||
... | ||
|
||
# Check we get the proper suggestion when all are imported | ||
try: | ||
... | ||
except BaseException: # ASYNC103_anyio_asyncio_trio: 7, "BaseException" | ||
... | ||
|
||
try: | ||
... | ||
except: # ASYNC103_anyio_asyncio_trio: 0, "bare except" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.