# Buggy code
def visit_import_all(self, i: ImportAll) -> None:
    i_id = self.correct_relative_import(i)
    if i_id in self.modules:
        m = self.modules[i_id]
        self.add_submodules_to_parent_modules(i_id, True)
        for name, node in m.names.items():
            node = self.normalize_type_alias(node, i)
            if not name.startswith("_") and node.module_public:
                existing_symbol = self.globals.get(name)
                if existing_symbol:
                    # Import can redefine a variable. They get special treatment.
                    if self.process_import_over_existing_name(
                        name, existing_symbol, node, i
                    ):
                        continue
                self.add_symbol(
                    name, SymbolTableNode(node.kind, node.node, self.cur_mod_id), i
                )
    else:
        # Don't add any dummy symbols for 'from x import *' if 'x' is unknown.
        pass


# Traceback (AttributeError)
ryan@DevPC-LX ~/blaze-mypy/bug master $ mypy x.py --show-traceback
x.py:1: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues
Traceback (most recent call last):
File "/media/ryan/stuff/anaconda/bin/mypy", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/media/ryan/stuff/mypy/scripts/mypy", line 6, in <module>
main(__file__)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/main.py", line 38, in main
res = type_check_only(sources, bin_dir, options)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/main.py", line 79, in type_check_only
options=options)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/build.py", line 184, in build
dispatch(sources, manager)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/build.py", line 1494, in dispatch
process_graph(graph, manager)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/build.py", line 1674, in process_graph
process_stale_scc(graph, scc)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/build.py", line 1751, in process_stale_scc
graph[id].semantic_analysis_pass_three()
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/build.py", line 1411, in semantic_analysis_pass_three
self.manager.semantic_analyzer_pass3.visit_file(self.tree, self.xpath, self.options)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/semanal.py", line 2871, in visit_file
self.accept(file_node)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/semanal.py", line 2875, in accept
node.accept(self)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/nodes.py", line 259, in accept
return visitor.visit_mypy_file(self)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/traverser.py", line 29, in visit_mypy_file
d.accept(self)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/nodes.py", line 815, in accept
return visitor.visit_assignment_stmt(self)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/semanal.py", line 2952, in visit_assignment_stmt
self.analyze(s.type)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/semanal.py", line 2972, in analyze
type.accept(analyzer)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/types.py", line 427, in accept
return visitor.visit_instance(self)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/typeanal.py", line 363, in visit_instance
if not satisfies_upper_bound(arg, TypeVar.upper_bound):
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/subtypes.py", line 75, in satisfies_upper_bound
return isinstance(a, Void) or is_subtype(a, upper_bound)
File "/media/stuff/anaconda/lib/python3.4/site-packages/mypy/subtypes.py", line 51, in is_subtype
return left.accept(SubtypeVisitor(right, type_parameter_checker))
AttributeError: 'NoneType' object has no attribute 'accept'
x.py:1: note: use --pdb to drop into pdb
ryan@DevPC-LX ~/blaze-mypy/bug master $

# Fixed code
def visit_import_all(self, i: ImportAll) -> None:
    i_id = self.correct_relative_import(i)
    if i_id in self.modules:
        m = self.modules[i_id]
        self.add_submodules_to_parent_modules(i_id, True)
        for name, node in m.names.items():
            node = self.normalize_type_alias(node, i)
            if not name.startswith("_") and node.module_public:
                existing_symbol = self.globals.get(name)
                if existing_symbol:
                    # Import can redefine a variable. They get special treatment.
                    if self.process_import_over_existing_name(
                        name, existing_symbol, node, i
                    ):
                        continue
                self.add_symbol(
                    name,
                    SymbolTableNode(
                        node.kind, node.node, self.cur_mod_id, node.type_override
                    ),
                    i,
                )
    else:
        # Don't add any dummy symbols for 'from x import *' if 'x' is unknown.
        pass