Skip to content

Pyrefly incorrectly flags async with block in Jupyter notebook. #3514

Closed

Description

@Terrigible

Describe the Bug

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

No response

Activity

  1. self-assigned this
    on May 22, 2026
  2. yangdanny97 commented on May 26, 2026

    @yangdanny97
    Collaborator

    This will be fixed in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions