| 1 |
import asyncio |
| 2 |
from functools import wraps |
| 3 |
|
| 4 |
|
| 5 |
class AsyncClass: |
| 6 |
async def do_coroutine(self): |
| 7 |
"""A documented coroutine function""" |
| 8 |
attr_coro_result = await _other_coro_func() |
| 9 |
|
| 10 |
@classmethod |
| 11 |
async def do_coroutine2(cls): |
| 12 |
"""A documented coroutine classmethod""" |
| 13 |
pass |
| 14 |
|
| 15 |
@staticmethod |
| 16 |
async def do_coroutine3(): |
| 17 |
"""A documented coroutine staticmethod""" |
| 18 |
pass |
| 19 |
|
| 20 |
async def do_asyncgen(self): |
| 21 |
"""A documented async generator""" |
| 22 |
yield |
| 23 |
|
| 24 |
|
| 25 |
async def _other_coro_func(): # NoQA: RUF029 |
| 26 |
return 'run' |
| 27 |
|
| 28 |
|
| 29 |
def myawait(f): |
| 30 |
@wraps(f) |
| 31 |
def wrapper(*args, **kwargs): |
| 32 |
awaitable = f(*args, **kwargs) |
| 33 |
return asyncio.run(awaitable) |
| 34 |
|
| 35 |
return wrapper |
| 36 |
|
| 37 |
|
| 38 |
sync_func = myawait(_other_coro_func) |