asyncio.gather return type from tasks.pyi seem to be different from the actual runtime type.
example.py
import asyncio
from typing import List
async def five() -> int:
return 5
async def runner() -> List[int]:
fives = await asyncio.gather(five(), five(), five())
print(type(fives)) # prints `<class 'list'>`
print(fives) # prints `[5, 5, 5]`
return fives
loop = asyncio.get_event_loop()
result: List[int] = loop.run_until_complete(runner())
$ python3 --version
Python 3.6.6
$ python3 example.py
<class 'list'>
[5, 5, 5]
$ mypy --version
mypy 0.641
$ mypy example.py
example.py:11: error: Incompatible return value type (got "Tuple[int, int, int]", expected "List[int]")
By looking at tasks.pyi I see no overload or any case where gather does not return a Tuple.
asyncio.gatherreturn type fromtasks.pyiseem to be different from the actual runtime type.example.py
By looking at
tasks.pyiI see no overload or any case wheregatherdoes not return aTuple.