Open
Description
Bug Report
I'm adding typing to a large codebase, and have noticed weird asyncio.gather
behavior.
To Reproduce
Here's a self-contained test:
from asyncio import gather
async def returns_dict() -> dict:
return {}
async def returns_int() -> int:
return 1
async def test():
tasks = (returns_dict(), returns_int())
reveal_type(await gather(*tasks)) # note: Revealed type is "Any"
Expected Behavior
The revealed type should be: note: Revealed type is "Tuple[builtins.dict*[Any, Any], builtins.int*]"
Actual Behavior
The correct return type is not recognized.
If the example is slightly changed:
from asyncio import gather
async def returns_dict() -> dict:
return {}
async def returns_int() -> int:
return 1
async def test():
reveal_type(await gather(returns_dict(), returns_int()))
it works properly.
Your Environment
- Mypy version used: 0.902
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files): allow_redefinition, check_untyped_defs, namespace_packages, warn_unreachable - Python version used: 3.9.5
- Operating system and version: macOs Big Sur