Skip to content

Crash with async generator and disallow_untyped_defs #5122

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

Closed
JelleZijlstra opened this issue May 30, 2018 · 0 comments
Closed

Crash with async generator and disallow_untyped_defs #5122

JelleZijlstra opened this issue May 30, 2018 · 0 comments

Comments

@JelleZijlstra
Copy link
Member

On this file:

from typing import AsyncGenerator, Awaitable, Callable, Any
import asyncio

async def f() -> AsyncGenerator[int, None]:
    yield 3
    await asyncio.sleep(1)

I get:

$ mypy --show-traceback --disallow-untyped-defs bin/asyncg.py 
bin/asyncg.py:4: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.610+dev-c29210ea2f79f4017ec68435b5674d56e87c5105
Traceback (most recent call last):
  File "/Users/jzijlstra-mpbt/py/venvs/venv36/bin/mypy", line 11, in <module>
    load_entry_point('mypy', 'console_scripts', 'mypy')()
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/__main__.py", line 7, in console_entry
    main(None)
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/main.py", line 91, in main
    res = type_check_only(sources, bin_dir, options, flush_errors, fscache)  # noqa
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/main.py", line 148, in type_check_only
    fscache=fscache)
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/build.py", line 185, in build
    flush_errors, fscache)
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/build.py", line 285, in _build
    graph = dispatch(sources, manager)
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/build.py", line 2398, in dispatch
    process_graph(graph, manager)
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/build.py", line 2691, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/build.py", line 2807, in process_stale_scc
    graph[id].type_check_first_pass()
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/build.py", line 2029, in type_check_first_pass
    self.type_checker().check_first_pass()
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/checker.py", line 252, in check_first_pass
    self.accept(d)
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/checker.py", line 351, in accept
    stmt.accept(self)
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/nodes.py", line 586, in accept
    return visitor.visit_func_def(self)
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/checker.py", line 654, in visit_func_def
    self._visit_func_def(defn)
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/checker.py", line 658, in _visit_func_def
    self.check_func_item(defn, name=defn.name())
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/checker.py", line 720, in check_func_item
    self.check_func_def(defn, typ, name)
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/checker.py", line 755, in check_func_def
    self.check_for_missing_annotations(fdef)
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/checker.py", line 933, in check_for_missing_annotations
    is_unannotated_any(self.get_coroutine_return_type(ret_type))):
  File "/Users/jzijlstra-mpbt/py/mypy/mypy/checker.py", line 626, in get_coroutine_return_type
    return return_type.args[2]
IndexError: list index out of range
bin/asyncg.py:4: : note: use --pdb to drop into pdb

If nobody else gets to it first, I can look into fixing this within the next few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant