When syncing typeshed in #11905, the type of asyncio.sleep was changed from:
def sleep(delay: float, result: _T = ...) -> Future[_T]: ... to async def sleep(delay: float, result: _T = ...) -> _T: ...
This change somehow exposed an issue in type inference.
The test expects the following to reveal Future[list[Any]] in the following, after the typeshed change, the test reveals Future[Any]:
reveal_type(asyncio.gather(*[asyncio.sleep(1), asyncio.sleep(1)]))
While investigating this I noticed something weird. If you add another reveal_type, mypy is once again able to infer the better Future[list[Any]] type. That is, the following shows Future[list[Any]] for the outer reveal_type.
reveal_type(asyncio.gather(*[reveal_type(asyncio.sleep(1)), asyncio.sleep(1)]))
When syncing typeshed in #11905, the type of
asyncio.sleepwas changed from:def sleep(delay: float, result: _T = ...) -> Future[_T]: ...toasync def sleep(delay: float, result: _T = ...) -> _T: ...This change somehow exposed an issue in type inference.
The test expects the following to reveal
Future[list[Any]]in the following, after the typeshed change, the test revealsFuture[Any]:While investigating this I noticed something weird. If you add another
reveal_type, mypy is once again able to infer the betterFuture[list[Any]]type. That is, the following showsFuture[list[Any]]for the outerreveal_type.