-
Notifications
You must be signed in to change notification settings - Fork 5.5k
tornado.gen.multi() results in mypy error #3142
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
Comments
I think this may be related to covariance (see https://mypy.readthedocs.io/en/stable/generics.html#variance-of-generic-types), like #3119. I think some uses of Dict in type annotations may need to be changed to Mapping (just like some uses of List should be replaced by Sequence). Annotating the type of |
Thanks for the workaround, but it didn't work for me. However, I've solved the problem by implementing my own version of
Since asyncio.gather preserves the order of the coroutines in the result list, this should behave identical to |
Yes, |
i'm experiencing this as well when using pyright. I'm seeing errors like this:
I suspect that changing the type annotation of |
#3142: Improve usability of multi() and multi_future() type annotations
Hi!
I've converted some old code from
tornado.gen
based coroutines to native coroutines, in order to be able to add static type checking using mypy (version0.950
). However, I've got some problems after replacing an oldyield [Dict[int, Future]]
call withtornado.gen.multi
:old call:
new call:
with
req_dict
being built like this:I thought that should work (according to the type annotations in the code), but I'm getting this
mypy
error:Am I doing sth. wrong or is this issue similar to #3093? Maybe
_Yieldable
should also allowFuture[Any]
? 🤔The text was updated successfully, but these errors were encountered: