Skip to content

Commit bb7f131

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 3145f0e commit bb7f131

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
@@ -240,13 +240,14 @@ type
240240

241241
**`# doctest: +SKIP` is NOT permitted** - it's just another workaround that doesn't test anything. Use the fixtures properly.
242242

243-
**Async doctest pattern:**
243+
**Async doctest pattern (top-level await):**
244244
```python
245+
>>> import asyncio
246+
>>> await asyncio.sleep(0) # Top-level await works directly
245247
>>> async def example():
246-
... result = await some_async_function()
247-
... return result
248-
>>> asyncio.run(example())
249-
'expected output'
248+
... return 42
249+
>>> await example()
250+
42
250251
```
251252

252253
**Using fixtures in doctests:**

0 commit comments

Comments
 (0)