-
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.
Fix miscellaneous issues in
await-outside-async detection
(#14218)
## Summary Closes #14167.
- Loading branch information
1 parent
b19f388
commit 93fdf7e
Showing
7 changed files
with
177 additions
and
31 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
62 changes: 55 additions & 7 deletions
62
...s/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1142_await_outside_async.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,19 +1,67 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pylint/mod.rs | ||
--- | ||
await_outside_async.py:12:11: PLE1142 `await` should be used within an async function | ||
await_outside_async.py:15:11: PLE1142 `await` should be used within an async function | ||
| | ||
11 | def not_async(): | ||
12 | print(await nested()) # [await-outside-async] | ||
14 | def not_async(): | ||
15 | print(await nested()) # [await-outside-async] | ||
| ^^^^^^^^^^^^^^ PLE1142 | ||
| | ||
|
||
await_outside_async.py:25:9: PLE1142 `await` should be used within an async function | ||
await_outside_async.py:29:9: PLE1142 `await` should be used within an async function | ||
| | ||
23 | async def func2(): | ||
24 | def inner_func(): | ||
25 | await asyncio.sleep(1) # [await-outside-async] | ||
27 | async def func2(): | ||
28 | def inner_func(): | ||
29 | await asyncio.sleep(1) # [await-outside-async] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ PLE1142 | ||
| | ||
|
||
await_outside_async.py:38:5: PLE1142 `await` should be used within an async function | ||
| | ||
37 | def async_for_loop(): | ||
38 | async for x in foo(): | ||
| _____^ | ||
39 | | pass | ||
| |____________^ PLE1142 | ||
| | ||
|
||
await_outside_async.py:43:5: PLE1142 `await` should be used within an async function | ||
| | ||
42 | def async_with(): | ||
43 | async with foo(): | ||
| _____^ | ||
44 | | pass | ||
| |____________^ PLE1142 | ||
| | ||
|
||
await_outside_async.py:54:6: PLE1142 `await` should be used within an async function | ||
| | ||
52 | # See: https://github.com/astral-sh/ruff/issues/14167 | ||
53 | def async_for_list_comprehension_elt(): | ||
54 | [await x for x in foo()] | ||
| ^^^^^^^ PLE1142 | ||
| | ||
|
||
await_outside_async.py:59:8: PLE1142 `await` should be used within an async function | ||
| | ||
57 | # See: https://github.com/astral-sh/ruff/issues/14167 | ||
58 | def async_for_list_comprehension(): | ||
59 | [x async for x in foo()] | ||
| ^^^^^^^^^^^^^^^^^^^^ PLE1142 | ||
| | ||
|
||
await_outside_async.py:64:17: PLE1142 `await` should be used within an async function | ||
| | ||
62 | # See: https://github.com/astral-sh/ruff/issues/14167 | ||
63 | def await_generator_iter(): | ||
64 | (x for x in await foo()) | ||
| ^^^^^^^^^^^ PLE1142 | ||
| | ||
|
||
await_outside_async.py:74:17: PLE1142 `await` should be used within an async function | ||
| | ||
72 | # See: https://github.com/astral-sh/ruff/issues/14167 | ||
73 | def async_for_list_comprehension_target(): | ||
74 | [x for x in await foo()] | ||
| ^^^^^^^^^^^ PLE1142 | ||
| |
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