I have a code which look like this:
import asyncio
from typing import List
def some_callback(result):
print(result)
async def b() -> List[int]:
return [1, 2, 3]
async def a() -> None:
search = asyncio.ensure_future(b())
search.add_done_callback( some_callback)
await search
loop = asyncio.get_event_loop()
loop.run_until_complete(a())
loop.close()
I am trying to add type annotations to the some_callback function, but I can't fully understand hoe to annotate the result variable. Should it be Coroutine? Or maybe Awaitable?
When I am using the reveal_type of mypy, the output about the result variable is Any.
The output of this program is:
<Task finished coro=<b() done, defined at ____.py:7> result=[1, 2, 3]>
How should I document this function properly?