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

isinstance() tuple unpacking raises mypy internal error #4986

Closed
trevorbaca opened this issue Apr 30, 2018 · 2 comments · Fixed by #6659
Closed

isinstance() tuple unpacking raises mypy internal error #4986

trevorbaca opened this issue Apr 30, 2018 · 2 comments · Fixed by #6659

Comments

@trevorbaca
Copy link

The tuple unpacking here ...

two_types = (list, tuple)                                                       
third_type = str                                                                
if isinstance('text', (*two_types, third_type)):                                
    print('hello')                                                              

... produces ...

mypy --show-traceback test.py
test.py:3: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.560
Traceback (most recent call last):
  File "/Users/trevorbaca/.virtualenvs/abjad3/bin/mypy", line 11, in <module>
    sys.exit(console_entry())
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/__main__.py", line 7, in console_entry
    main(None)
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/main.py", line 66, in main
    res = type_check_only(sources, bin_dir, options)
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/main.py", line 119, in type_check_only
    options=options)
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/build.py", line 218, in build
    graph = dispatch(sources, manager)
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/build.py", line 1997, in dispatch
    process_graph(graph, manager)
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/build.py", line 2299, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/build.py", line 2475, in process_stale_scc
    graph[id].type_check_first_pass()
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/build.py", line 1876, in type_check_first_pass
    self.type_checker().check_first_pass()
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/checker.py", line 196, in check_first_pass
    self.accept(d)
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/checker.py", line 286, in accept
    stmt.accept(self)
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/nodes.py", line 921, in accept
    return visitor.visit_if_stmt(self)
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/checker.py", line 2181, in visit_if_stmt
    t = self.expr_checker.accept(e)
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/checkexpr.py", line 2365, in accept
    typ = node.accept(self)
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/nodes.py", line 1245, in accept
    return visitor.visit_call_expr(self)
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/checkexpr.py", line 271, in visit_call_expr
    self.check_runtime_protocol_test(e)
  File "/Users/trevorbaca/.virtualenvs/abjad3/lib/python3.6/site-packages/mypy/checkexpr.py", line 283, in check_runtime_protocol_test
    tp = self.chk.type_map[expr]
KeyError: <mypy.nodes.StarExpr object at 0x10cb639b0>
test.py:3: : note: use --pdb to drop into pdb

... when run by mypy.

@gvanrossum
Copy link
Member

Confirmed on master and in release-0.600.

@ilevkivskyi
Copy link
Member

(This looks like an old bug so setting priority to normal.)

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

Successfully merging a pull request may close this issue.

3 participants