-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary Update the name of `ASYNC109` to match [upstream](https://flake8-async.readthedocs.io/en/latest/rules.html). Also update to the functionality to match upstream by supporting additional context managers from `asyncio` and `anyio`. This doesn't change any of the detection functionality, but recommends additional context managers from `asyncio` and `anyio` depending on context. Part of #12039. ## Test Plan Added fixture for asyncio recommendation
- Loading branch information
1 parent
10f07d8
commit 16a63c8
Showing
12 changed files
with
147 additions
and
27 deletions.
There are no files selected for viewing
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
crates/ruff_linter/resources/test/fixtures/flake8_async/ASYNC109_1.py
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,10 @@ | ||
async def func(): | ||
... | ||
|
||
|
||
async def func(timeout): | ||
... | ||
|
||
|
||
async def func(timeout=10): | ||
... |
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
6 changes: 4 additions & 2 deletions
6
...8_async__tests__ASYNC109_ASYNC109.py.snap → ...async__tests__ASYNC109_ASYNC109_0.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,16 +1,18 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_async/mod.rs | ||
--- | ||
ASYNC109.py:8:16: ASYNC109 Prefer `trio.fail_after` and `trio.move_on_after` over manual `async` timeout behavior | ||
ASYNC109_0.py:8:16: ASYNC109 Async function definition with a `timeout` parameter | ||
| | ||
8 | async def func(timeout): | ||
| ^^^^^^^ ASYNC109 | ||
9 | ... | ||
| | ||
= help: Use `trio.fail_after` instead | ||
|
||
ASYNC109.py:12:16: ASYNC109 Prefer `trio.fail_after` and `trio.move_on_after` over manual `async` timeout behavior | ||
ASYNC109_0.py:12:16: ASYNC109 Async function definition with a `timeout` parameter | ||
| | ||
12 | async def func(timeout=10): | ||
| ^^^^^^^^^^ ASYNC109 | ||
13 | ... | ||
| | ||
= help: Use `trio.fail_after` instead |
4 changes: 4 additions & 0 deletions
4
...ake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC109_ASYNC109_1.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_async/mod.rs | ||
--- | ||
|
18 changes: 18 additions & 0 deletions
18
...c/snapshots/ruff_linter__rules__flake8_async__tests__preview__ASYNC109_ASYNC109_0.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_async/mod.rs | ||
--- | ||
ASYNC109_0.py:8:16: ASYNC109 Async function definition with a `timeout` parameter | ||
| | ||
8 | async def func(timeout): | ||
| ^^^^^^^ ASYNC109 | ||
9 | ... | ||
| | ||
= help: Use `trio.fail_after` instead | ||
|
||
ASYNC109_0.py:12:16: ASYNC109 Async function definition with a `timeout` parameter | ||
| | ||
12 | async def func(timeout=10): | ||
| ^^^^^^^^^^ ASYNC109 | ||
13 | ... | ||
| | ||
= help: Use `trio.fail_after` instead |
18 changes: 18 additions & 0 deletions
18
...c/snapshots/ruff_linter__rules__flake8_async__tests__preview__ASYNC109_ASYNC109_1.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_async/mod.rs | ||
--- | ||
ASYNC109_1.py:5:16: ASYNC109 Async function definition with a `timeout` parameter | ||
| | ||
5 | async def func(timeout): | ||
| ^^^^^^^ ASYNC109 | ||
6 | ... | ||
| | ||
= help: Use `asyncio.timeout` instead | ||
|
||
ASYNC109_1.py:9:16: ASYNC109 Async function definition with a `timeout` parameter | ||
| | ||
9 | async def func(timeout=10): | ||
| ^^^^^^^^^^ ASYNC109 | ||
10 | ... | ||
| | ||
= help: Use `asyncio.timeout` instead |
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