# Buggy code
def analyze_base_classes(self, defn: ClassDef) -> None:
    """Analyze and set up base classes.

    This computes several attributes on the corresponding TypeInfo defn.info
    related to the base classes: defn.info.bases, defn.info.mro, and
    miscellaneous others (at least tuple_type, fallback_to_any, and is_enum.)
    """

    base_types = []  # type: List[Instance]
    for base_expr in defn.base_type_exprs:
        try:
            base = self.expr_to_analyzed_type(base_expr)
        except TypeTranslationError:
            self.fail("Invalid base class", base_expr)
            defn.info.fallback_to_any = True
            continue

        if isinstance(base, TupleType):
            if defn.info.tuple_type:
                self.fail("Class has two incompatible bases derived from tuple", defn)
            if (
                not self.is_stub_file
                and not defn.info.is_named_tuple
                and base.fallback.type.fullname() == "builtins.tuple"
            ):
                self.fail(
                    "Tuple[...] not supported as a base class outside a stub file", defn
                )
            defn.info.tuple_type = base
            base_types.append(base.fallback)
        elif isinstance(base, Instance):
            base_types.append(base)
        elif isinstance(base, AnyType):
            defn.info.fallback_to_any = True
        else:
            self.fail("Invalid base class", base_expr)
            defn.info.fallback_to_any = True

    # Add 'object' as implicit base if there is no other base class.
    if not base_types and defn.fullname != "builtins.object":
        base_types.append(self.object_type())

    defn.info.bases = base_types

    # Calculate the MRO. It might be incomplete at this point if
    # the bases of defn include classes imported from other
    # modules in an import loop. We'll recompute it in ThirdPass.
    if not self.verify_base_classes(defn):
        # Give it an MRO consisting of just the class itself and object.
        defn.info.mro = [defn.info, self.object_type().type]
        return
    calculate_class_mro(defn, self.fail)
    # If there are cyclic imports, we may be missing 'object' in
    # the MRO. Fix MRO if needed.
    if defn.info.mro and defn.info.mro[-1].fullname() != "builtins.object":
        defn.info.mro.append(self.object_type().type)


# Traceback (AttributeError)
Traceback (most recent call last):
File "C:\Program Files\Python35\Scripts\mypy", line 6, in <module>
main(__file__)
File "C:\Program Files\Python35\lib\site-packages\mypy\main.py", line 54, in main
res = type_check_only(sources, bin_dir, options)
File "C:\Program Files\Python35\lib\site-packages\mypy\main.py", line 102, in type_check_only
python_path=options.python_path)
File "C:\Program Files\Python35\lib\site-packages\mypy\build.py", line 211, in build
dispatch(sources, manager)
File "C:\Program Files\Python35\lib\site-packages\mypy\build.py", line 1336, in dispatch
process_graph(graph, manager)
File "C:\Program Files\Python35\lib\site-packages\mypy\build.py", line 1467, in process_graph
process_stale_scc(graph, scc)
File "C:\Program Files\Python35\lib\site-packages\mypy\build.py", line 1497, in process_stale_scc
graph[id].type_check()
File "C:\Program Files\Python35\lib\site-packages\mypy\build.py", line 1316, in type_check
manager.type_checker.visit_file(self.tree, self.xpath)
File "C:\Program Files\Python35\lib\site-packages\mypy\checker.py", line 426, in visit_file
self.accept(d)
File "C:\Program Files\Python35\lib\site-packages\mypy\checker.py", line 476, in accept
typ = node.accept(self)
File "C:\Program Files\Python35\lib\site-packages\mypy\nodes.py", line 650, in accept
return visitor.visit_class_def(self)
File "C:\Program Files\Python35\lib\site-packages\mypy\checker.py", line 1068, in visit_class_def
self.check_multiple_inheritance(typ)
File "C:\Program Files\Python35\lib\site-packages\mypy\checker.py", line 1093, in check_multiple_inheritance
if not (base1 in base2.mro or base2 in base1.mro):
AttributeError: 'NoneType' object has no attribute 'mro'

*** INTERNAL ERROR ***

mypybug.py:20: error: Internal error -- please report a bug at https://github.com/python/mypy/issues

NOTE: you can use "mypy --pdb ..." to drop into the debugger when this happens.

# Fixed code
def analyze_base_classes(self, defn: ClassDef) -> None:
    """Analyze and set up base classes.

    This computes several attributes on the corresponding TypeInfo defn.info
    related to the base classes: defn.info.bases, defn.info.mro, and
    miscellaneous others (at least tuple_type, fallback_to_any, and is_enum.)
    """

    base_types = []  # type: List[Instance]
    for base_expr in defn.base_type_exprs:
        try:
            base = self.expr_to_analyzed_type(base_expr)
        except TypeTranslationError:
            self.fail("Invalid base class", base_expr)
            defn.info.fallback_to_any = True
            continue

        if isinstance(base, TupleType):
            if defn.info.tuple_type:
                self.fail("Class has two incompatible bases derived from tuple", defn)
            if (
                not self.is_stub_file
                and not defn.info.is_named_tuple
                and base.fallback.type.fullname() == "builtins.tuple"
            ):
                self.fail(
                    "Tuple[...] not supported as a base class outside a stub file", defn
                )
            defn.info.tuple_type = base
            base_types.append(base.fallback)
        elif isinstance(base, Instance):
            base_types.append(base)
        elif isinstance(base, AnyType):
            defn.info.fallback_to_any = True
        else:
            self.fail("Invalid base class", base_expr)
            defn.info.fallback_to_any = True

    # Add 'object' as implicit base if there is no other base class.
    if not base_types and defn.fullname != "builtins.object":
        base_types.append(self.object_type())

    defn.info.bases = base_types

    # Calculate the MRO. It might be incomplete at this point if
    # the bases of defn include classes imported from other
    # modules in an import loop. We'll recompute it in ThirdPass.
    if not self.verify_base_classes(defn):
        # Give it an MRO consisting of just the class itself and object.
        defn.info.mro = [defn.info, self.object_type().type]
        return
    calculate_class_mro(defn, self.fail_blocker)
    # If there are cyclic imports, we may be missing 'object' in
    # the MRO. Fix MRO if needed.
    if defn.info.mro and defn.info.mro[-1].fullname() != "builtins.object":
        defn.info.mro.append(self.object_type().type)