[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:
GiGaGon 2025-06-28 08:15:34 -07:00 committed by GitHub
parent 523174e8be
commit 315adba906
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)
/// ```