Skip to content

Crash unpacking tuple in argument list #1795

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
scott-ainsworth opened this issue Jul 3, 2016 · 2 comments
Closed

Crash unpacking tuple in argument list #1795

scott-ainsworth opened this issue Jul 3, 2016 · 2 comments

Comments

@scott-ainsworth
Copy link

The following code produces a NotImplementedError using Python 3.5.2 and mypy 0.4.2-dev (commit commit e7e9c4a):

from typing import Any, List, Optional, Tuple

def count(items: Optional[List[Any]]) -> Tuple[int, str]:
    """Return item count and English singular/plural ('' or 's')."""
    if not items:
        return 0, 's'
    count = len(items)
    return count, '' if count == 1 else 's'

items = [1, 2, 3]
print('{0} items{1}'.format(*count(items)))

Here is the command line and stack dump:

$ mypy --disallow-untyped-defs --disallow-untyped-calls mypy-failure.py
Traceback (most recent call last):
  File "/Volumes/Research/python35-venv/bin/mypy", line 6, in <module>
    main(__file__)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/main.py", line 54, in main
    res = type_check_only(sources, bin_dir, options)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/main.py", line 102, in type_check_only
    python_path=options.python_path)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/build.py", line 209, in build
    dispatch(sources, manager)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/build.py", line 1329, in dispatch
    process_graph(graph, manager)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/build.py", line 1460, in process_graph
    process_stale_scc(graph, scc)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/build.py", line 1490, in process_stale_scc
    graph[id].type_check()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/build.py", line 1309, in type_check
    manager.type_checker.visit_file(self.tree, self.xpath)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 424, in visit_file
    self.accept(d)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 465, in accept
    typ = node.accept(self)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/nodes.py", line 729, in accept
    return visitor.visit_expression_stmt(self)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 1570, in visit_expression_stmt
    self.accept(s.expr)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 465, in accept
    typ = node.accept(self)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/nodes.py", line 1185, in accept
    return visitor.visit_call_expr(self)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 1993, in visit_call_expr
    return self.expr_checker.visit_call_expr(e)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checkexpr.py", line 141, in visit_call_expr
    return self.check_call_expr_with_callee_type(callee_type, e)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checkexpr.py", line 192, in check_call_expr_with_callee_type
    e.arg_names, callable_node=e.callee)[0]
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checkexpr.py", line 235, in check_call
    callee, args, arg_kinds, formal_to_actual)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checkexpr.py", line 330, in infer_arg_types_in_context2
    res[ai] = self.accept(args[ai], callee.arg_types[i])
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checkexpr.py", line 1491, in accept
    return self.chk.accept(node, context)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 465, in accept
    typ = node.accept(self)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/nodes.py", line 1185, in accept
    return visitor.visit_call_expr(self)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 1993, in visit_call_expr
    return self.expr_checker.visit_call_expr(e)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checkexpr.py", line 141, in visit_call_expr
    return self.check_call_expr_with_callee_type(callee_type, e)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checkexpr.py", line 192, in check_call_expr_with_callee_type
    e.arg_names, callable_node=e.callee)[0]
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checkexpr.py", line 226, in check_call
    lambda i: self.accept(args[i]))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checkexpr.py", line 1589, in map_actuals_to_formals
    raise NotImplementedError()
NotImplementedError:

*** INTERNAL ERROR ***```
@scott-ainsworth scott-ainsworth changed the title Crash unpacking function return in argument list Crash unpacking tuple in argument list Jul 3, 2016
@refi64
Copy link
Contributor

refi64 commented Jul 3, 2016

Duplicate of #1553?

@scott-ainsworth
Copy link
Author

Oops, sure looks like it.

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

No branches or pull requests

3 participants