mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[flake8-async
] Make ASYNC251
example error out-of-the-box (#18990)
## Summary Part of #18972 This PR makes [blocking-sleep-in-async-function (ASYNC251)](https://docs.astral.sh/ruff/rules/blocking-sleep-in-async-function/#blocking-sleep-in-async-function-async251)'s example error out-of-the-box [Old example](https://play.ruff.rs/796684a2-c437-4390-b754-491e576ffe5e) ```py async def fetch(): time.sleep(1) ``` [New example](https://play.ruff.rs/90741192-fd0d-49fb-a04e-3127312da659) ```py import time async def fetch(): time.sleep(1) ``` Imports were also added to the `Use instead:` section to make it valid code out-of-the-box. ## Test Plan <!-- How was it tested? --> N/A, no functionality/tests affected
This commit is contained in:
parent
523174e8be
commit
315adba906
1 changed files with 6 additions and 0 deletions
|
@ -19,12 +19,18 @@ use crate::checkers::ast::Checker;
|
|||
///
|
||||
/// ## Example
|
||||
/// ```python
|
||||
/// import time
|
||||
///
|
||||
///
|
||||
/// async def fetch():
|
||||
/// time.sleep(1)
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```python
|
||||
/// import asyncio
|
||||
///
|
||||
///
|
||||
/// async def fetch():
|
||||
/// await asyncio.sleep(1)
|
||||
/// ```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue