Skip to content

Commit a903a44

Browse files
committed
ai(rules[AGENTS]): Update async doctest pattern to top-level await
why: Document the new capability enabled by AsyncDocTestRunner what: - Replace asyncio.run() boilerplate with top-level await syntax - Show that await works directly in doctests now
1 parent fecd38d commit a903a44

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

AGENTS.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,14 @@ True
248248
>>> is_allowed_version('3.3', '>3.2, <4.0')
249249
True
250250

251-
**Async doctest pattern:**
251+
**Async doctest pattern (top-level await):**
252252
```python
253+
>>> import asyncio
254+
>>> await asyncio.sleep(0) # Top-level await works directly
253255
>>> async def example():
254-
... result = await some_async_function()
255-
... return result
256-
>>> asyncio.run(example())
257-
'expected output'
256+
... return 42
257+
>>> await example()
258+
42
258259
```
259260

260261
**Using fixtures in doctests:**

0 commit comments

Comments
 (0)