Skip to content

mypy-0.641 is crashed with AssertionError: Var is lacking info #5866

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
tk0miya opened this issue Nov 2, 2018 · 6 comments
Closed

mypy-0.641 is crashed with AssertionError: Var is lacking info #5866

tk0miya opened this issue Nov 2, 2018 · 6 comments

Comments

@tk0miya
Copy link

tk0miya commented Nov 2, 2018

  • Are you reporting a bug, or opening a feature request?

Bug report.

  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.

Here: https://github.com/tk0miya/sphinx/tree/mypy_py37_bug

This is our repository. Now I'm working to migrate type annotations to py3 style.

  • What is the actual behavior/output?

mypy has been crashed with following stacktrace.

sphinx/util/docutils.py:61: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.641
Traceback (most recent call last):
  File "/Users/tkomiya/.pyenv/versions/3.7.1/bin/mypy", line 11, in <module>
    sys.exit(console_entry())
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/__main__.py", line 7, in console_entry
    main(None)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/main.py", line 92, in main
    res = build.build(sources, options, None, flush_errors, fscache)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/build.py", line 155, in build
    result = _build(sources, options, alt_lib_path, flush_errors, fscache)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/build.py", line 204, in _build
    graph = dispatch(sources, manager)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/build.py", line 2172, in dispatch
    process_graph(graph, manager)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/build.py", line 2469, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/build.py", line 2592, in process_stale_scc
    graph[id].type_check_first_pass()
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/build.py", line 1730, in type_check_first_pass
    self.type_checker().check_first_pass()
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 282, in check_first_pass
    self.accept(d)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 393, in accept
    stmt.accept(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/nodes.py", line 688, in accept
    return visitor.visit_decorator(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 3002, in visit_decorator
    self.check_func_item(e.func, name=e.func.name())
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 770, in check_func_item
    self.check_func_def(defn, typ, name)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 934, in check_func_def
    self.accept(item.body)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 393, in accept
    stmt.accept(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/nodes.py", line 910, in accept
    return visitor.visit_block(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 1688, in visit_block
    self.accept(s)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 393, in accept
    stmt.accept(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/nodes.py", line 1137, in accept
    return visitor.visit_try_stmt(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 2808, in visit_try_stmt
    self.accept(s.finally_body)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 393, in accept
    stmt.accept(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/nodes.py", line 910, in accept
    return visitor.visit_block(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 1688, in visit_block
    self.accept(s)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 393, in accept
    stmt.accept(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/nodes.py", line 965, in accept
    return visitor.visit_assignment_stmt(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 1696, in visit_assignment_stmt
    self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 1751, in check_assignment
    if self.check_compatibility_all_supers(lvalue, lvalue_type, rvalue):
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 1822, in check_compatibility_all_supers
    len(lvalue_node.info.bases) > 0):
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/nodes.py", line 2488, in __getattribute__
    raise AssertionError(object.__getattribute__(self, 'msg'))
AssertionError: Var is lacking info
sphinx/util/docutils.py:61: : note: use --pdb to drop into pdb
  • What is the behavior/output you expect?

Not crashed.

  • What are the versions of mypy and Python you are using?
    Do you see the same issue after installing mypy from Git master?

python 3.7.1 and 0.641.
I never tested with git master version.

  • What are the mypy flags you are using? (For example --strict-optional)

Here is my setup.cfg:

[mypy]
show_column_numbers = True
show_error_context = True
ignore_missing_imports = True
follow_imports = skip
incremental = True
check_untyped_defs = True
warn_unused_ignores = True
strict_optional = False
@ilevkivskyi
Copy link
Member

Hm, this is unfortunate, sorry. Could try to find a minimalistic repro containing only one or few files?

@tk0miya
Copy link
Author

tk0miya commented Nov 11, 2018

Sorry for late response. This is minimal reproducible example. Could you check this please?

$ ls -lR
total 8
-rw-r--r--  1 tkomiya  staff  102 11 11 14:18 roles.py
$ cat roles.py
# -*- coding: utf-8 -*-
from docutils.parsers.rst import roles

def enable(self):
    roles.role = {}
$ mypy -V
mypy 0.641
$ mypy roles.py
roles.py:5: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.641
roles.py:5: : note: please use --show-traceback to print a traceback when reporting a bug
$ mypy --show-traceback roles.py
roles.py:5: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.641
Traceback (most recent call last):
  File "/Users/tkomiya/.pyenv/versions/3.7.1/bin/mypy", line 11, in <module>
    sys.exit(console_entry())
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/__main__.py", line 7, in console_entry
    main(None)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/main.py", line 92, in main
    res = build.build(sources, options, None, flush_errors, fscache)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/build.py", line 155, in build
    result = _build(sources, options, alt_lib_path, flush_errors, fscache)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/build.py", line 204, in _build
    graph = dispatch(sources, manager)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/build.py", line 2172, in dispatch
    process_graph(graph, manager)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/build.py", line 2469, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/build.py", line 2592, in process_stale_scc
    graph[id].type_check_first_pass()
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/build.py", line 1730, in type_check_first_pass
    self.type_checker().check_first_pass()
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 282, in check_first_pass
    self.accept(d)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 393, in accept
    stmt.accept(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/nodes.py", line 608, in accept
    return visitor.visit_func_def(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 704, in visit_func_def
    self._visit_func_def(defn)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 708, in _visit_func_def
    self.check_func_item(defn, name=defn.name())
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 770, in check_func_item
    self.check_func_def(defn, typ, name)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 934, in check_func_def
    self.accept(item.body)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 393, in accept
    stmt.accept(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/nodes.py", line 910, in accept
    return visitor.visit_block(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 1688, in visit_block
    self.accept(s)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 393, in accept
    stmt.accept(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/nodes.py", line 965, in accept
    return visitor.visit_assignment_stmt(self)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 1696, in visit_assignment_stmt
    self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 1751, in check_assignment
    if self.check_compatibility_all_supers(lvalue, lvalue_type, rvalue):
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/checker.py", line 1822, in check_compatibility_all_supers
    len(lvalue_node.info.bases) > 0):
  File "/Users/tkomiya/.pyenv/versions/3.7.1/lib/python3.7/site-packages/mypy/nodes.py", line 2488, in __getattribute__
    raise AssertionError(object.__getattribute__(self, 'msg'))
AssertionError: Var is lacking info
roles.py:5: : note: use --pdb to drop into pdb

@mkurnikov
Copy link
Contributor

More minimal example (as a test case):

[case testName]
import roles

roles.role = 1

[file roles.pyi]
def __getattr__(name): ...

@ilevkivskyi
Copy link
Member

Oh, great, it will me much easier to fix it with this repro.

@ilevkivskyi
Copy link
Member

@tk0miya Could you please double-check that #5893 fixes your original crash

ilevkivskyi added a commit that referenced this issue Nov 15, 2018
Fixes #5866

There are two places where `__getattr__` generated `Var`s are created, and somehow in one of them it was given a `MDEF` kind (which caused a crash), although it is a _module_ attribute.
@tk0miya
Copy link
Author

tk0miya commented Nov 24, 2018

Sorry for late. I confirmed it works fine on our project!
Thank you for your work!

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

3 participants