# Buggy code
def setup_class_def_analysis(self, defn: ClassDef) -> None:
    """Prepare for the analysis of a class definition."""
    if not defn.info:
        defn.info = TypeInfo(SymbolTable(), defn, self.cur_mod_id)
        defn.info._fullname = defn.info.name()
    if self.is_func_scope() or self.type:
        kind = MDEF
        if self.is_func_scope():
            kind = LDEF
        self.add_symbol(defn.name, SymbolTableNode(kind, defn.info), defn)


# Traceback (AssertionError)
$ rm -rf .mypy_cache/
$ mypy -i main.py
main.py:1: error: Name 'blah' is not defined
$ mypy -i main.py
Traceback (most recent call last):
File "/usr/local/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/guido/src/mypy/mypy/__main__.py", line 5, in <module>
main(None)
File "/Users/guido/src/mypy/mypy/main.py", line 41, in main
res = type_check_only(sources, bin_dir, options)
File "/Users/guido/src/mypy/mypy/main.py", line 86, in type_check_only
options=options)
File "/Users/guido/src/mypy/mypy/build.py", line 183, in build
dispatch(sources, manager)
File "/Users/guido/src/mypy/mypy/build.py", line 1524, in dispatch
process_graph(graph, manager)
File "/Users/guido/src/mypy/mypy/build.py", line 1753, in process_graph
process_fresh_scc(graph, prev_scc)
File "/Users/guido/src/mypy/mypy/build.py", line 1822, in process_fresh_scc
graph[id].fix_cross_refs()
File "/Users/guido/src/mypy/mypy/build.py", line 1307, in fix_cross_refs
fixup_module_pass_one(self.tree, self.manager.modules)
File "/Users/guido/src/mypy/mypy/fixup.py", line 21, in fixup_module_pass_one
node_fixer.visit_symbol_table(tree.names)
File "/Users/guido/src/mypy/mypy/fixup.py", line 86, in visit_symbol_table
self.visit_type_info(value.node)
File "/Users/guido/src/mypy/mypy/fixup.py", line 55, in visit_type_info
self.visit_symbol_table(info.names)
File "/Users/guido/src/mypy/mypy/fixup.py", line 88, in visit_symbol_table
value.node.accept(self)
File "/Users/guido/src/mypy/mypy/nodes.py", line 658, in accept
return visitor.visit_var(self)
File "/Users/guido/src/mypy/mypy/fixup.py", line 131, in visit_var
v.type.accept(self.type_fixer)
File "/Users/guido/src/mypy/mypy/types.py", line 433, in accept
return visitor.visit_instance(self)
File "/Users/guido/src/mypy/mypy/fixup.py", line 144, in visit_instance
node = lookup_qualified(self.modules, type_ref)
File "/Users/guido/src/mypy/mypy/fixup.py", line 234, in lookup_qualified
stnode = lookup_qualified_stnode(modules, name)
File "/Users/guido/src/mypy/mypy/fixup.py", line 245, in lookup_qualified_stnode
assert '.' in head, "Cannot find %s" % (name,)
AssertionError: Cannot find A

# Fixed code
def setup_class_def_analysis(self, defn: ClassDef) -> None:
    """Prepare for the analysis of a class definition."""
    if not defn.info:
        defn.info = TypeInfo(SymbolTable(), defn, self.cur_mod_id)
        defn.info._fullname = defn.info.name()
    if self.is_func_scope() or self.type:
        kind = MDEF
        if self.is_func_scope():
            kind = LDEF
        node = SymbolTableNode(kind, defn.info)
        self.add_symbol(defn.name, node, defn)
        if kind == LDEF:
            # We need to preserve local classes, let's store them
            # in globals under mangled unique names
            local_name = defn.info._fullname + "@" + str(defn.line)
            defn.info._fullname = self.cur_mod_id + "." + local_name
            defn.fullname = defn.info._fullname
            self.globals[local_name] = node