-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Error with asyncio.sleep()
: Argument type is partially unknown
#3475
Comments
For reference, async def sleep(delay: float, result: _T = ...) -> _T: ... So it makes sense that pyright can't infer the return value if the |
Yeah, I agree with Jelle that the definition for @overload
async def sleep(delay: float) -> None: ...
@overload
async def sleep(delay: float, result: _T) -> _T: ... Please file a bug (or even better, a PR!) in the typeshed project. Pyright regularly picks up updates to typeshed stubs. In the meantime, you can work around the problem by adding an explicit argument for the |
Thanks! I've filed an issue on typeshed. |
Closes #7866. This adds an overload to `asyncio.sleep()`, so that when it is called _without_ `return=None`, the type checker knows that the return type is `None` instead of `unknown`. Also related to microsoft/pyright#3475.
I'm not sure if this is an issue with pyright or with typeshed, so please let me know if it belongs in typeshed.
With the latest version of pyright (1.1.247), this code results in an error:
The result when I run
pyright
on it:However, if
result
is specified, it passes:Similarly, if I create a wrapper function for
asyncio.sleep()
where the return type is explicitly set toNone
, it passes:The text was updated successfully, but these errors were encountered: