Skip to content

Commit ed2e903

Browse files
authored
[flake8-async] Make ASYNC210 example error out-of-the-box (astral-sh#18977)
## Summary Part of astral-sh#18972 This PR makes [blocking-http-call-in-async-function (ASYNC210)](https://docs.astral.sh/ruff/rules/blocking-http-call-in-async-function/#blocking-http-call-in-async-function-async210)'s example error out-of-the-box [Old example](https://play.ruff.rs/20cba4f4-fe2f-428a-a721-311d1a081e64) ```py async def fetch(): urllib.request.urlopen("https://example.com/foo/bar").read() ``` [New example](https://play.ruff.rs/5ca2a10d-5294-49ee-baee-0447f7188d9b) ```py import urllib async def fetch(): urllib.request.urlopen("https://example.com/foo/bar").read() ``` ## Test Plan <!-- How was it tested? --> N/A, no functionality/tests affected
1 parent 90cb0d3 commit ed2e903

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_http_call.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@ use crate::checkers::ast::Checker;
2020
///
2121
/// ## Example
2222
/// ```python
23+
/// import urllib
24+
///
25+
///
2326
/// async def fetch():
2427
/// urllib.request.urlopen("https://example.com/foo/bar").read()
2528
/// ```
2629
///
2730
/// Use instead:
2831
/// ```python
32+
/// import aiohttp
33+
///
34+
///
2935
/// async def fetch():
3036
/// async with aiohttp.ClientSession() as session:
3137
/// async with session.get("https://example.com/foo/bar") as resp:

0 commit comments

Comments
 (0)