-
-
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.
ASYNC102 no longer raises warning for calls to
.aclose()
on objects (…
…#222) * ASYNC102 no longer raises warning for calls to `.aclose()` on objects * bump __version__ * fixes after review: allow aclose() in except clauses. Only allow if no args. Don't exempt asyncio-only code. * lol I was so confused why this started failing
- Loading branch information
Showing
7 changed files
with
96 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# type: ignore | ||
|
||
# exclude finally: await x.aclose() from async102, with trio/anyio | ||
# ANYIO_NO_ERROR | ||
# TRIO_NO_ERROR | ||
# See also async102_aclose_args.py - which makes sure trio/anyio raises errors if there | ||
# are arguments to aclose(). | ||
|
||
|
||
async def foo(): | ||
# no type tracking in this check, we allow any call that looks like | ||
# `await [...].aclose()` | ||
x = None | ||
|
||
try: | ||
... | ||
except BaseException: | ||
await x.aclose() # ASYNC102: 8, Statement("BaseException", lineno-1) | ||
await x.y.aclose() # ASYNC102: 8, Statement("BaseException", lineno-2) | ||
finally: | ||
await x.aclose() # ASYNC102: 8, Statement("try/finally", lineno-6) | ||
await x.y.aclose() # ASYNC102: 8, Statement("try/finally", lineno-7) |
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,24 @@ | ||
# type: ignore | ||
|
||
# trio/anyio should still raise errors if there's args | ||
# asyncio will always raise errors | ||
|
||
# See also async102_aclose.py, which checks that trio/anyio marks arg-less aclose() as safe | ||
|
||
|
||
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) |
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