mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +00:00
[flake8-async
] Make ASYNC210
example error out-of-the-box (#18977)
## Summary Part of #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
This commit is contained in:
parent
90cb0d3a7b
commit
ed2e90371b
1 changed files with 6 additions and 0 deletions
|
@ -20,12 +20,18 @@ use crate::checkers::ast::Checker;
|
|||
///
|
||||
/// ## Example
|
||||
/// ```python
|
||||
/// import urllib
|
||||
///
|
||||
///
|
||||
/// async def fetch():
|
||||
/// urllib.request.urlopen("https://example.com/foo/bar").read()
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```python
|
||||
/// import aiohttp
|
||||
///
|
||||
///
|
||||
/// async def fetch():
|
||||
/// async with aiohttp.ClientSession() as session:
|
||||
/// async with session.get("https://example.com/foo/bar") as resp:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue