-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flake8-async] Fix false positives with multiple async with
items (ASYNC100
)
#12643
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 8 additions & 8 deletions
16
...flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_async/mod.rs | ||
--- | ||
ASYNC100.py:7:5: ASYNC100 A `with trio.fail_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
ASYNC100.py:8:5: ASYNC100 A `with trio.fail_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
| | ||
6 | async def func(): | ||
7 | async with trio.fail_after(): | ||
7 | async def func(): | ||
8 | with trio.fail_after(): | ||
| _____^ | ||
8 | | ... | ||
9 | | ... | ||
| |___________^ ASYNC100 | ||
| | ||
|
||
ASYNC100.py:17:5: ASYNC100 A `with trio.move_on_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
ASYNC100.py:18:5: ASYNC100 A `with trio.move_on_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
| | ||
16 | async def func(): | ||
17 | async with trio.move_on_after(): | ||
17 | async def func(): | ||
18 | with trio.move_on_after(): | ||
| _____^ | ||
18 | | ... | ||
19 | | ... | ||
| |___________^ ASYNC100 | ||
| |
91 changes: 59 additions & 32 deletions
91
...ync/snapshots/ruff_linter__rules__flake8_async__tests__preview__ASYNC100_ASYNC100.py.snap
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 |
---|---|---|
@@ -1,74 +1,101 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_async/mod.rs | ||
--- | ||
ASYNC100.py:7:5: ASYNC100 A `with trio.fail_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
ASYNC100.py:8:5: ASYNC100 A `with trio.fail_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
| | ||
6 | async def func(): | ||
7 | async with trio.fail_after(): | ||
7 | async def func(): | ||
8 | with trio.fail_after(): | ||
| _____^ | ||
8 | | ... | ||
9 | | ... | ||
| |___________^ ASYNC100 | ||
| | ||
|
||
ASYNC100.py:17:5: ASYNC100 A `with trio.move_on_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
ASYNC100.py:18:5: ASYNC100 A `with trio.move_on_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
| | ||
16 | async def func(): | ||
17 | async with trio.move_on_after(): | ||
17 | async def func(): | ||
18 | with trio.move_on_after(): | ||
| _____^ | ||
18 | | ... | ||
19 | | ... | ||
| |___________^ ASYNC100 | ||
| | ||
|
||
ASYNC100.py:33:5: ASYNC100 A `with anyio.move_on_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
ASYNC100.py:40:5: ASYNC100 A `with anyio.move_on_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
| | ||
32 | async def func(): | ||
33 | async with anyio.move_on_after(delay=0.2): | ||
39 | async def func(): | ||
40 | with anyio.move_on_after(delay=0.2): | ||
| _____^ | ||
34 | | ... | ||
41 | | ... | ||
| |___________^ ASYNC100 | ||
| | ||
|
||
ASYNC100.py:38:5: ASYNC100 A `with anyio.fail_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
ASYNC100.py:45:5: ASYNC100 A `with anyio.fail_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
| | ||
37 | async def func(): | ||
38 | async with anyio.fail_after(): | ||
44 | async def func(): | ||
45 | with anyio.fail_after(): | ||
| _____^ | ||
39 | | ... | ||
46 | | ... | ||
| |___________^ ASYNC100 | ||
| | ||
|
||
ASYNC100.py:43:5: ASYNC100 A `with anyio.CancelScope(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
ASYNC100.py:50:5: ASYNC100 A `with anyio.CancelScope(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
| | ||
42 | async def func(): | ||
43 | async with anyio.CancelScope(): | ||
49 | async def func(): | ||
50 | with anyio.CancelScope(): | ||
| _____^ | ||
44 | | ... | ||
51 | | ... | ||
| |___________^ ASYNC100 | ||
| | ||
|
||
ASYNC100.py:48:5: ASYNC100 A `with anyio.CancelScope(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
ASYNC100.py:55:5: ASYNC100 A `with anyio.CancelScope(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
| | ||
47 | async def func(): | ||
48 | async with anyio.CancelScope(): | ||
54 | async def func(): | ||
55 | with anyio.CancelScope(), nullcontext(): | ||
| _____^ | ||
49 | | ... | ||
56 | | ... | ||
| |___________^ ASYNC100 | ||
| | ||
|
||
ASYNC100.py:53:5: ASYNC100 A `with asyncio.timeout(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
ASYNC100.py:60:5: ASYNC100 A `with anyio.CancelScope(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
| | ||
52 | async def func(): | ||
53 | async with asyncio.timeout(delay=0.2): | ||
59 | async def func(): | ||
60 | with nullcontext(), anyio.CancelScope(): | ||
| _____^ | ||
54 | | ... | ||
61 | | ... | ||
| |___________^ ASYNC100 | ||
| | ||
|
||
ASYNC100.py:58:5: ASYNC100 A `with asyncio.timeout_at(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
ASYNC100.py:65:5: ASYNC100 A `with asyncio.timeout(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
| | ||
57 | async def func(): | ||
58 | async with asyncio.timeout_at(when=0.2): | ||
64 | async def func(): | ||
65 | async with asyncio.timeout(delay=0.2): | ||
| _____^ | ||
59 | | ... | ||
66 | | ... | ||
| |___________^ ASYNC100 | ||
| | ||
|
||
ASYNC100.py:70:5: ASYNC100 A `with asyncio.timeout_at(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
| | ||
69 | async def func(): | ||
70 | async with asyncio.timeout_at(when=0.2): | ||
| _____^ | ||
71 | | ... | ||
| |___________^ ASYNC100 | ||
| | ||
|
||
ASYNC100.py:80:5: ASYNC100 A `with asyncio.timeout(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
| | ||
79 | async def func(): | ||
80 | async with asyncio.timeout(delay=0.2), asyncio.TaskGroup(), asyncio.timeout(delay=0.2): | ||
| _____^ | ||
81 | | ... | ||
| |___________^ ASYNC100 | ||
| | ||
|
||
ASYNC100.py:90:5: ASYNC100 A `with asyncio.timeout(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. | ||
| | ||
89 | async def func(): | ||
90 | async with asyncio.timeout(delay=0.2), asyncio.timeout(delay=0.2): | ||
| _____^ | ||
91 | | ... | ||
| |___________^ ASYNC100 | ||
| |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
trio
andanyio
context managers are notasync
. The difference is relevant for this change, so I changed them back towith
, this way we test bothwith
andasync with
(asyncio).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that's my bad!