Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in testAsyncioGatherPreciseType #12089

Open
hauntsaninja opened this issue Jan 28, 2022 · 0 comments
Open

Regression in testAsyncioGatherPreciseType #12089

hauntsaninja opened this issue Jan 28, 2022 · 0 comments
Labels
bug mypy got something wrong topic-async async, await, asyncio

Comments

@hauntsaninja
Copy link
Collaborator

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)]))
@hauntsaninja hauntsaninja added the bug mypy got something wrong label Jan 28, 2022
@AlexWaygood AlexWaygood added the topic-async async, await, asyncio label Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-async async, await, asyncio
Projects
None yet
Development

No branches or pull requests

2 participants