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

Exception while typechecking python3.4 program using asyncio.Queue.get #868

Closed
thomascellerier opened this issue Sep 3, 2015 · 0 comments
Labels
bug mypy got something wrong

Comments

@thomascellerier
Copy link

Using the latest master from today mypy 0.2.0-dev.

Traceback (most recent call last):
  File "/usr/local/bin/mypy", line 184, in <module>
    main()
  File "/usr/local/bin/mypy", line 36, in main
    type_check_only(path, module, bin_dir, options)
  File "/usr/local/bin/mypy", line 80, in type_check_only
    python_path=options.python_path)
  File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 160, in build
    result = manager.process(UnprocessedFile(info, program_text))
  File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 337, in process
    next.process()
  File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 786, in process
    self.type_checker().visit_file(self.tree, self.tree.path)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 353, in visit_file
    self.accept(d)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 360, in accept
    typ = node.accept(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/nodes.py", line 380, in accept
    return visitor.visit_decorator(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 1646, in visit_decorator
    e.func.accept(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/nodes.py", line 349, in accept
    return visitor.visit_func_def(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 417, in visit_func_def
    self.check_func_item(defn, name=defn.name())
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 450, in check_func_item
    self.check_func_def(defn, typ, name)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 517, in check_func_def
    self.accept_in_frame(item.body)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 373, in accept_in_frame
    answer = self.accept(node, type_context)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 360, in accept
    typ = node.accept(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/nodes.py", line 493, in accept
    return visitor.visit_block(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 907, in visit_block
    self.accept(s)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 360, in accept
    typ = node.accept(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/nodes.py", line 532, in accept
    return visitor.visit_assignment_stmt(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 916, in visit_assignment_stmt
    self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 944, in check_assignment
    self.infer_variable_type(inferred, lvalue, self.accept(rvalue),
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 360, in accept
    typ = node.accept(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/nodes.py", line 944, in accept
    return visitor.visit_yield_from_expr(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 1693, in visit_yield_from_expr
    if result_instance.type.fullname() == "asyncio.futures.Future":
AttributeError: 'AnyType' object has no attribute 'type'

Here is a minimal program to reproduce:

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())
@thomascellerier thomascellerier changed the title Exception while typechecking python3.4 program using asyncio Exception while typechecking python3.4 program using asyncio.Queue.get Sep 3, 2015
rockneurotiko added a commit to rockneurotiko/mypy that referenced this issue Sep 10, 2015
…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
```
@JukkaL JukkaL added the bug mypy got something wrong label Oct 1, 2015
msullivan added a commit that referenced this issue Jun 8, 2021
And avoid triggering mypy assertion failures on errors.

Fixes #866.
Opened #868 to track the async feature work.
msullivan added a commit that referenced this issue Aug 17, 2022
Also fix returning a value from inside a try block when the finally block
does a yield. (Which happens when returning from an async with).

Progress on mypyc/mypyc##868.
msullivan added a commit that referenced this issue Aug 18, 2022
Also fix returning a value from inside a try block when the finally block
does a yield. (Which happens when returning from an async with).

Progress on mypyc/mypyc##868.
msullivan added a commit that referenced this issue Aug 18, 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
Projects
None yet
Development

No branches or pull requests

3 participants