Skip to content

Commit 315adba

Browse files
authored
[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
1 parent 523174e commit 315adba

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

crates/ruff_linter/src/rules/flake8_async/rules/blocking_sleep.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@ use crate::checkers::ast::Checker;
1919
///
2020
/// ## Example
2121
/// ```python
22+
/// import time
23+
///
24+
///
2225
/// async def fetch():
2326
/// time.sleep(1)
2427
/// ```
2528
///
2629
/// Use instead:
2730
/// ```python
31+
/// import asyncio
32+
///
33+
///
2834
/// async def fetch():
2935
/// await asyncio.sleep(1)
3036
/// ```

0 commit comments

Comments
 (0)