-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Traceback analysing asyncio "item = yield from queue.get()" #836
Comments
That's probably because queue.get() should return a Future[T] or Future[Any], not Any. |
Thanks for reporting this! I was able to reproduce the issue. |
I'm not familiar with mypy internals but I stepped through the analysis of this in pdb and found a couple of things:
Only after all three fixes are applied the attribute error goes away. I'm submitting a PR with fixed Queue stubs ( @asyncio.coroutine
def test_put(self) -> None:
queue = asyncio.Queue(16384)
yield from queue.put(123) does tell me that I need a type annotation for
Again, it works if I explicitly add |
I think the problem is more generic: import asyncio
import typing
@asyncio.coroutine
def foo(a):
b = yield from a
return b gives me:
|
…xample that @nierob reported in python#836) Now don't crash in: ``` import asyncio @asyncio.coroutine def example_coro(): q = asyncio.Queue() msg = yield from q.get() if __name__ == '__main__': loop = asyncio.get_event_loop() loop.run_until_complete(example_coro()) ``` But that example is because don't infer asyncio.Queue type properly as is appointed in python#836, so q is AnyType and ``` import asyncio import typing @asyncio.coroutine def foo(a): b = yield from a return b ```
Analysing:
Result:
The text was updated successfully, but these errors were encountered: