# Buggy code
def analyze_namedtuple_classdef(self, defn: ClassDef) -> bool:
    # special case for NamedTuple
    for base_expr in defn.base_type_exprs:
        if isinstance(base_expr, RefExpr):
            base_expr.accept(self)
            if base_expr.fullname == "typing.NamedTuple":
                node = self.lookup(defn.name, defn)
                if node is not None:
                    node.kind = (
                        GDEF  # TODO in process_namedtuple_definition also applies here
                    )
                    items, types, default_items = self.check_namedtuple_classdef(defn)
                    node.node = self.build_namedtuple_typeinfo(
                        defn.name, items, types, default_items
                    )
                    return True
    return False


# Traceback (TypeError)
Traceback (most recent call last):
File "/Users/daenyth/Curata/observer/.tox/mypy/bin/mypy", line 6, in <module>
main(__file__)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/main.py", line 46, in main
res = type_check_only(sources, bin_dir, options)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/main.py", line 93, in type_check_only
options=options)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/build.py", line 188, in build
graph = dispatch(sources, manager)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/build.py", line 1595, in dispatch
process_graph(graph, manager)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/build.py", line 1838, in process_graph
process_stale_scc(graph, scc, manager)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/build.py", line 1937, in process_stale_scc
graph[id].type_check_first_pass()
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/build.py", line 1510, in type_check_first_pass
self.type_checker.check_first_pass()
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/checker.py", line 177, in check_first_pass
self.accept(d)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/checker.py", line 264, in accept
stmt.accept(self)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/nodes.py", line 749, in accept
return visitor.visit_class_def(self)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/checker.py", line 1080, in visit_class_def
self.accept(defn.defs)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/checker.py", line 264, in accept
stmt.accept(self)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/nodes.py", line 810, in accept
return visitor.visit_block(self)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/checker.py", line 1173, in visit_block
self.accept(s)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/checker.py", line 264, in accept
stmt.accept(self)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/nodes.py", line 631, in accept
return visitor.visit_decorator(self)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/checker.py", line 2213, in visit_decorator
e.func.accept(self)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/nodes.py", line 564, in accept
return visitor.visit_func_def(self)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/checker.py", line 513, in visit_func_def
self.check_method_override(defn)
File "/Users/daenyth/Curata/observer/.tox/mypy/lib/python3.6/site-packages/mypy/checker.py", line 945, in check_method_override
for base in defn.info.mro[1:]:
TypeError: 'NoneType' object is not subscriptable

# Fixed code
def analyze_namedtuple_classdef(self, defn: ClassDef) -> bool:
    # special case for NamedTuple
    for base_expr in defn.base_type_exprs:
        if isinstance(base_expr, RefExpr):
            base_expr.accept(self)
            if base_expr.fullname == "typing.NamedTuple":
                node = self.lookup(defn.name, defn)
                if node is not None:
                    node.kind = (
                        GDEF  # TODO in process_namedtuple_definition also applies here
                    )
                    items, types, default_items = self.check_namedtuple_classdef(defn)
                    node.node = self.build_namedtuple_typeinfo(
                        defn.name, items, types, default_items
                    )
                    # We only really need the assignments in the body to be type checked later;
                    # attempting to type check methods may lead to crashes because NamedTuples
                    # do not have a fully functional TypeInfo.
                    # TODO remove this hack and add full support for NamedTuple methods
                    defn.defs.body = [
                        stmt
                        for stmt in defn.defs.body
                        if isinstance(stmt, AssignmentStmt)
                    ]
                    return True
    return False