You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pyrefly incorrectly flags async with block in Jupyter notebook. #3514
Pyrefly does not recognise that you can use async with outside of an async function in Jupyter notebooks.
Code:
import httpx
import asyncio
async with httpx.AsyncClient() as client:
tasks = (client.get("https://pyrefly.org") for _ in range(2))
responses = await asyncio.gather(*tasks)
Partial output of pyrefly check:
ERROR `async with` can only be used inside an async function [invalid-syntax]
--> test2.ipynb#2:1:1
|
1 | / async with httpx.AsyncClient() as client:
2 | | tasks = (client.get("https://pyrefly.org") for _ in range(2))
3 | | responses = await asyncio.gather(*tasks)
| |____________________________________________^
|
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
Activity
yangdanny97 commentedon May 26, 2026
This will be fixed in the next release
Allow `async with` and `async for` at top level in notebooks