[ty] Test for @asynccontextmanager

This commit is contained in:
David Peter 2025-12-08 12:59:28 +01:00
parent dfd6ed0524
commit 07efdf8887
1 changed files with 18 additions and 0 deletions

View File

@ -82,6 +82,24 @@ async def main():
reveal_type(b) # revealed: int
```
### `asynccontextmanager`
```py
from contextlib import asynccontextmanager
from typing import AsyncGenerator
class Session: ...
@asynccontextmanager
async def connect() -> AsyncGenerator[Session]:
yield Session()
async def main():
async with connect() as session:
# TODO: should be `Session`
reveal_type(session) # revealed: Unknown
```
## Under the hood
```toml