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

Crash on type: ignore in import #1327

Closed
drewhaven opened this issue Apr 4, 2016 · 1 comment
Closed

Crash on type: ignore in import #1327

drewhaven opened this issue Apr 4, 2016 · 1 comment
Labels
bug mypy got something wrong

Comments

@drewhaven
Copy link

We have some code to the effect of

if IS_LINUX:
    from linux_class import SomeClass
elif IS_MAC:
    from mac_class import SomeClass
elif IS_WINDOWS:
    from windows_class import SomeClass

assert SomeClass

Because SomeClass doesn't have quite the same interface in all three places, I tried to add type: ignore to the second and third imports. This caused the following crash while running mypy:

  File "/code/client-all/client/.mypy_lint/mypy/mypy/main.py", line 51, in main
    type_check_only(sources, bin_dir, options)
  File "/code/client-all/client/.mypy_lint/mypy/mypy/main.py", line 95, in type_check_only
    python_path=options.python_path)
  File "/code/client-all/client/.mypy_lint/mypy/mypy/build.py", line 239, in build
    result = manager.process(initial_states)
  File "/code/client-all/client/.mypy_lint/mypy/mypy/build.py", line 456, in process
    next.process()
  File "/code/client-all/client/.mypy_lint/mypy/mypy/build.py", line 964, in process
    self.type_checker().visit_file(self.tree, self.tree.path)
  File "/code/client-all/client/.mypy_lint/mypy/mypy/checker.py", line 416, in visit_file
    self.accept(d)
  File "/code/client-all/client/.mypy_lint/mypy/mypy/checker.py", line 457, in accept
    typ = node.accept(self)
  File "/code/client-all/client/.mypy_lint/mypy/mypy/nodes.py", line 632, in accept
    return visitor.visit_assert_stmt(self)
  File "/code/client-all/client/.mypy_lint/mypy/mypy/checker.py", line 1710, in visit_assert_stmt
    self.accept(s.expr)
  File "/code/client-all/client/.mypy_lint/mypy/mypy/checker.py", line 457, in accept
    typ = node.accept(self)
  File "/code/client-all/client/.mypy_lint/mypy/mypy/nodes.py", line 902, in accept
    return visitor.visit_name_expr(self)
  File "/code/client-all/client/.mypy_lint/mypy/mypy/checker.py", line 1961, in visit_name_expr
    return self.expr_checker.visit_name_expr(e)
  File "/code/client-all/client/.mypy_lint/mypy/mypy/checkexpr.py", line 75, in visit_name_expr
    result = self.analyze_ref_expr(e)
  File "/code/client-all/client/.mypy_lint/mypy/mypy/checkexpr.py", line 103, in analyze_ref_expr
    result = type_object_type(node, self.named_type)
  File "/code/client-all/client/.mypy_lint/mypy/mypy/checkmember.py", line 320, in type_object_type
    init_method = info.get_method('__init__')
  File "/code/client-all/client/.mypy_lint/mypy/mypy/nodes.py", line 1593, in get_method
    for cls in self.mro:
TypeError: 'NoneType' object is not iterable

I've spent some time trying to get a small example of how to repro this, but haven't been able to yet.

@JukkaL
Copy link
Collaborator

JukkaL commented Apr 5, 2016

This seems like a special case of #1107 that causes a crash. It would be useful to understand why this happens even if we won't implement #1107 very soon.

@JukkaL JukkaL added the bug mypy got something wrong label Apr 5, 2016
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

2 participants