# Buggy code
def check_method_override_for_base_with_name(
    self, defn: FuncBase, name: str, base: TypeInfo
) -> None:
    base_attr = base.names.get(name)
    if base_attr:
        # The name of the method is defined in the base class.

        # Construct the type of the overriding method.
        typ = self.method_type(defn)
        # Map the overridden method type to subtype context so that
        # it can be checked for compatibility.
        original_type = base_attr.type
        if original_type is None and isinstance(base_attr.node, FuncDef):
            original_type = self.function_type(base_attr.node)
        if isinstance(original_type, FunctionLike):
            original = map_type_from_supertype(
                method_type(original_type), defn.info, base
            )
            # Check that the types are compatible.
            # TODO overloaded signatures
            self.check_override(
                typ, cast(FunctionLike, original), defn.name(), name, base.name(), defn
            )
        else:
            assert original_type is not None
            self.msg.signature_incompatible_with_supertype(
                defn.name(), name, base.name(), defn
            )


# Traceback (AssertionError)
Traceback (most recent call last):
File ".../bin/mypy", line 6, in <module>
main(__file__)
File ".../mypy/main.py", line 40, in main
res = type_check_only(sources, bin_dir, options)
File ".../mypy/main.py", line 81, in type_check_only
options=options)
File ".../mypy/build.py", line 177, in build
dispatch(sources, manager)
File ".../mypy/build.py", line 1323, in dispatch
process_graph(graph, manager)
File ".../mypy/build.py", line 1461, in process_graph
process_stale_scc(graph, scc)
File ".../mypy/build.py", line 1538, in process_stale_scc
graph[id].type_check()
File ".../mypy/build.py", line 1301, in type_check
manager.type_checker.visit_file(self.tree, self.xpath)
File ".../mypy/checker.py", line 152, in visit_file
self.accept(d)
File ".../mypy/checker.py", line 201, in accept
typ = node.accept(self)
File ".../mypy/nodes.py", line 660, in accept
return visitor.visit_class_def(self)
File ".../mypy/checker.py", line 802, in visit_class_def
self.accept(defn.defs)
File ".../mypy/checker.py", line 201, in accept
typ = node.accept(self)
File ".../mypy/nodes.py", line 723, in accept
return visitor.visit_block(self)
File ".../mypy/checker.py", line 897, in visit_block
self.accept(s)
File ".../mypy/checker.py", line 201, in accept
typ = node.accept(self)
File ".../mypy/nodes.py", line 475, in accept
return visitor.visit_func_def(self)
File ".../mypy/checker.py", line 325, in visit_func_def
self.check_method_override(defn)
File ".../mypy/checker.py", line 681, in check_method_override
self.check_method_or_accessor_override_for_base(defn, base)
File ".../mypy/checker.py", line 690, in check_method_or_accessor_override_for_base
self.check_method_override_for_base_with_name(defn, name, base)
File ".../mypy/checker.py", line 728, in check_method_override_for_base_with_name
assert original_type is not None
AssertionError:

*** INTERNAL ERROR ***

/home/machinalis/0/foo/derived.py:4: error: Internal error -- please report a bug at https://github.com/python/mypy/issues

# Fixed code
def check_method_override_for_base_with_name(
    self, defn: FuncBase, name: str, base: TypeInfo
) -> None:
    base_attr = base.names.get(name)
    if base_attr:
        # The name of the method is defined in the base class.

        # Construct the type of the overriding method.
        typ = self.method_type(defn)
        # Map the overridden method type to subtype context so that
        # it can be checked for compatibility.
        original_type = base_attr.type
        if original_type is None:
            if isinstance(base_attr.node, FuncDef):
                original_type = self.function_type(base_attr.node)
            elif isinstance(base_attr.node, Decorator):
                original_type = self.function_type(base_attr.node.func)
            else:
                assert False, str(base_attr.node)
        if isinstance(original_type, FunctionLike):
            original = map_type_from_supertype(
                method_type(original_type), defn.info, base
            )
            # Check that the types are compatible.
            # TODO overloaded signatures
            self.check_override(
                typ, cast(FunctionLike, original), defn.name(), name, base.name(), defn
            )
        else:
            self.msg.signature_incompatible_with_supertype(
                defn.name(), name, base.name(), defn
            )