# Buggy code
def check_argument_types(
    self,
    arg_types: List[Type],
    arg_kinds: List[int],
    callee: CallableType,
    formal_to_actual: List[List[int]],
    context: Context,
    messages: MessageBuilder = None,
    check_arg: ArgChecker = None,
) -> None:
    """Check argument types against a callable type.

    Report errors if the argument types are not compatible.
    """
    messages = messages or self.msg
    check_arg = check_arg or self.check_arg
    # Keep track of consumed tuple *arg items.
    tuple_counter = [0]
    for i, actuals in enumerate(formal_to_actual):
        for actual in actuals:
            arg_type = arg_types[actual]
            # Check that a *arg is valid as varargs.
            if arg_kinds[actual] == nodes.ARG_STAR and not self.is_valid_var_arg(
                arg_type
            ):
                messages.invalid_var_arg(arg_type, context)
            if arg_kinds[
                actual
            ] == nodes.ARG_STAR2 and not self.is_valid_keyword_var_arg(arg_type):
                messages.invalid_keyword_var_arg(arg_type, context)
            # Get the type of an individual actual argument (for *args
            # and **args this is the item type, not the collection type).
            actual_type = get_actual_type(arg_type, arg_kinds[actual], tuple_counter)
            check_arg(
                actual_type,
                arg_type,
                arg_kinds[actual],
                callee.arg_types[i],
                actual + 1,
                i + 1,
                callee,
                context,
                messages,
            )

            # There may be some remaining tuple varargs items that haven't
            # been checked yet. Handle them.
            if (
                callee.arg_kinds[i] == nodes.ARG_STAR
                and arg_kinds[actual] == nodes.ARG_STAR
                and isinstance(arg_types[actual], TupleType)
            ):
                tuplet = cast(TupleType, arg_types[actual])
                while tuple_counter[0] < len(tuplet.items):
                    actual_type = get_actual_type(
                        arg_type, arg_kinds[actual], tuple_counter
                    )
                    check_arg(
                        actual_type,
                        arg_type,
                        arg_kinds[actual],
                        callee.arg_types[i],
                        actual + 1,
                        i + 1,
                        callee,
                        context,
                        messages,
                    )


# Traceback (AttributeError)
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.5/site-packages/mypy/__main__.py", line 5, in <module>
main(None)
File "/usr/local/lib/python3.5/site-packages/mypy/main.py", line 40, in main
res = type_check_only(sources, bin_dir, options)
File "/usr/local/lib/python3.5/site-packages/mypy/main.py", line 81, in type_check_only
options=options)
File "/usr/local/lib/python3.5/site-packages/mypy/build.py", line 177, in build
dispatch(sources, manager)
File "/usr/local/lib/python3.5/site-packages/mypy/build.py", line 1323, in dispatch
process_graph(graph, manager)
File "/usr/local/lib/python3.5/site-packages/mypy/build.py", line 1461, in process_graph
process_stale_scc(graph, scc)
File "/usr/local/lib/python3.5/site-packages/mypy/build.py", line 1538, in process_stale_scc
graph[id].type_check()
File "/usr/local/lib/python3.5/site-packages/mypy/build.py", line 1301, in type_check
manager.type_checker.visit_file(self.tree, self.xpath)
File "/usr/local/lib/python3.5/site-packages/mypy/checker.py", line 152, in visit_file
self.accept(d)
File "/usr/local/lib/python3.5/site-packages/mypy/checker.py", line 201, in accept
typ = node.accept(self)
File "/usr/local/lib/python3.5/site-packages/mypy/nodes.py", line 737, in accept
return visitor.visit_expression_stmt(self)
File "/usr/local/lib/python3.5/site-packages/mypy/checker.py", line 1333, in visit_expression_stmt
self.accept(s.expr)
File "/usr/local/lib/python3.5/site-packages/mypy/checker.py", line 201, in accept
typ = node.accept(self)
File "/usr/local/lib/python3.5/site-packages/mypy/nodes.py", line 1445, in accept
return visitor.visit_list_expr(self)
File "/usr/local/lib/python3.5/site-packages/mypy/checker.py", line 1859, in visit_list_expr
return self.expr_checker.visit_list_expr(e)
File "/usr/local/lib/python3.5/site-packages/mypy/checkexpr.py", line 1283, in visit_list_expr
e)
File "/usr/local/lib/python3.5/site-packages/mypy/checkexpr.py", line 1303, in check_list_or_set_expr
[nodes.ARG_POS] * len(items), context)[0]
File "/usr/local/lib/python3.5/site-packages/mypy/checkexpr.py", line 253, in check_call
messages=arg_messages)
File "/usr/local/lib/python3.5/site-packages/mypy/checkexpr.py", line 677, in check_argument_types
actual + 1, i + 1, callee, context, messages)
File "/usr/local/lib/python3.5/site-packages/mypy/checkexpr.py", line 702, in check_arg
elif not is_subtype(caller_type, callee_type):
File "/usr/local/lib/python3.5/site-packages/mypy/subtypes.py", line 51, in is_subtype
return left.accept(SubtypeVisitor(right, type_parameter_checker))
AttributeError: 'NoneType' object has no attribute 'accept'

*** INTERNAL ERROR ***

unpacking.py:3: 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 check_argument_types(
    self,
    arg_types: List[Type],
    arg_kinds: List[int],
    callee: CallableType,
    formal_to_actual: List[List[int]],
    context: Context,
    messages: MessageBuilder = None,
    check_arg: ArgChecker = None,
) -> None:
    """Check argument types against a callable type.

    Report errors if the argument types are not compatible.
    """
    messages = messages or self.msg
    check_arg = check_arg or self.check_arg
    # Keep track of consumed tuple *arg items.
    tuple_counter = [0]
    for i, actuals in enumerate(formal_to_actual):
        for actual in actuals:
            arg_type = arg_types[actual]
            if arg_type is None:
                continue  # Some kind of error was already reported.
            # Check that a *arg is valid as varargs.
            if arg_kinds[actual] == nodes.ARG_STAR and not self.is_valid_var_arg(
                arg_type
            ):
                messages.invalid_var_arg(arg_type, context)
            if arg_kinds[
                actual
            ] == nodes.ARG_STAR2 and not self.is_valid_keyword_var_arg(arg_type):
                messages.invalid_keyword_var_arg(arg_type, context)
            # Get the type of an individual actual argument (for *args
            # and **args this is the item type, not the collection type).
            actual_type = get_actual_type(arg_type, arg_kinds[actual], tuple_counter)
            check_arg(
                actual_type,
                arg_type,
                arg_kinds[actual],
                callee.arg_types[i],
                actual + 1,
                i + 1,
                callee,
                context,
                messages,
            )

            # There may be some remaining tuple varargs items that haven't
            # been checked yet. Handle them.
            if (
                callee.arg_kinds[i] == nodes.ARG_STAR
                and arg_kinds[actual] == nodes.ARG_STAR
                and isinstance(arg_types[actual], TupleType)
            ):
                tuplet = cast(TupleType, arg_types[actual])
                while tuple_counter[0] < len(tuplet.items):
                    actual_type = get_actual_type(
                        arg_type, arg_kinds[actual], tuple_counter
                    )
                    check_arg(
                        actual_type,
                        arg_type,
                        arg_kinds[actual],
                        callee.arg_types[i],
                        actual + 1,
                        i + 1,
                        callee,
                        context,
                        messages,
                    )