Skip to content

Regression in testAsyncioGatherPreciseType #12089

Closed
@hauntsaninja

Description

@hauntsaninja

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)]))

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-asyncasync, await, asyncio

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions