# Buggy code
def visit_ImportFrom(self, n: ast3.ImportFrom) -> ImportBase:
    assert n.level is not None
    if len(n.names) == 1 and n.names[0].name == "*":
        assert n.module is not None
        i = ImportAll(n.module, n.level)  # type: ImportBase
    else:
        i = ImportFrom(
            self.translate_module_id(n.module) if n.module is not None else "",
            n.level,
            [(a.name, a.asname) for a in n.names],
        )
    self.imports.append(i)
    return i


# Traceback (AssertionError)
Traceback (most recent call last):
File "/path/py3env/bin/mypy", line 11, in <module>
sys.exit(console_entry())
File "/path/py3env/lib/python3.5/site-packages/mypy/__main__.py", line 7, in console_entry
main(None)
File "/path/py3env/lib/python3.5/site-packages/mypy/main.py", line 50, in main
res = type_check_only(sources, bin_dir, options)
File "/path/py3env/lib/python3.5/site-packages/mypy/main.py", line 103, in type_check_only
options=options)
File "/path/py3env/lib/python3.5/site-packages/mypy/build.py", line 198, in build
graph = dispatch(sources, manager)
File "/path/py3env/lib/python3.5/site-packages/mypy/build.py", line 1833, in dispatch
graph = load_graph(sources, manager)
File "/path/py3env/lib/python3.5/site-packages/mypy/build.py", line 1946, in load_graph
caller_state=st, caller_line=st.dep_line_map.get(dep, 1))
File "/path/py3env/lib/python3.5/site-packages/mypy/build.py", line 1466, in __init__
self.parse_file()
File "/path/py3env/lib/python3.5/site-packages/mypy/build.py", line 1663, in parse_file
self.ignore_all or self.options.ignore_errors)
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/path/py3env/lib/python3.5/site-packages/mypy/build.py", line 1554, in wrap_context
yield
File "/path/py3env/lib/python3.5/site-packages/mypy/build.py", line 1663, in parse_file
self.ignore_all or self.options.ignore_errors)
File "/path/py3env/lib/python3.5/site-packages/mypy/build.py", line 589, in parse_file
tree = parse(source, path, self.errors, options=self.options)
File "/path/py3env/lib/python3.5/site-packages/mypy/parse.py", line 25, in parse
options=options)
File "/path/py3env/lib/python3.5/site-packages/mypy/fastparse.py", line 96, in parse
).visit(ast)
File "/path/py3env/lib/python3.5/site-packages/mypy/fastparse.py", line 169, in visit
return super().visit(node)
File "/path/py3env/lib/python3.5/site-packages/typed_ast/ast3.py", line 275, in visit
return visitor(node)
File "/path/py3env/lib/python3.5/site-packages/mypy/fastparse.py", line 289, in visit_Module
body = self.fix_function_overloads(self.translate_stmt_list(mod.body))
File "/path/py3env/lib/python3.5/site-packages/mypy/fastparse.py", line 182, in translate_stmt_list
stmt = self.visit(e)
File "/path/py3env/lib/python3.5/site-packages/mypy/fastparse.py", line 169, in visit
return super().visit(node)
File "/path/py3env/lib/python3.5/site-packages/typed_ast/ast3.py", line 275, in visit
return visitor(node)
File "/path/py3env/lib/python3.5/site-packages/mypy/fastparse.py", line 126, in wrapper
node = f(self, ast)
File "/path/py3env/lib/python3.5/site-packages/mypy/fastparse.py", line 654, in visit_ImportFrom
assert n.module is not None
AssertionError:

# Fixed code
def visit_ImportFrom(self, n: ast3.ImportFrom) -> ImportBase:
    assert n.level is not None
    if len(n.names) == 1 and n.names[0].name == "*":
        mod = n.module if n.module is not None else ""
        i = ImportAll(mod, n.level)  # type: ImportBase
    else:
        i = ImportFrom(
            self.translate_module_id(n.module) if n.module is not None else "",
            n.level,
            [(a.name, a.asname) for a in n.names],
        )
    self.imports.append(i)
    return i