As title. Currently you have to def
ine two distinct functions.
I’m not proposing a solution. The “not” is because I’m really doubtful about it.
Instead of writing:
async def f():
[some code]
await some_coro()
await some_task
you could be able to write it also as:
def f() -> MaybeCoro[[], None]:
[some code]
some_coro()
some_task
I know, this is almost surely impossible, since the type hint in this case should act as a sort of keyword of the parser. Furthermore in this case, all coroutines and tasks will be awaited by default, and I don’t know if there’s a case in which is good to not await them and, if so, how to do it in the second code (maybe using asyncio.create_task()
?)