async def run_ast_nodes(self, nodelist: ListType[stmt], cell_name: str, interactivity='last_expr', compiler=compile, result=None):
    "Run a sequence of AST nodes. The execution mode depends on the\n        interactivity parameter.\n\n        Parameters\n        ----------\n        nodelist : list\n          A sequence of AST nodes to run.\n        cell_name : str\n          Will be passed to the compiler as the filename of the cell. Typically\n          the value returned by ip.compile.cache(cell).\n        interactivity : str\n          'all', 'last', 'last_expr' , 'last_expr_or_assign' or 'none',\n          specifying which nodes should be run interactively (displaying output\n          from expressions). 'last_expr' will run the last node interactively\n          only if it is an expression (i.e. expressions in loops or other blocks\n          are not displayed) 'last_expr_or_assign' will run the last expression\n          or the last assignment. Other values for this parameter will raise a\n          ValueError.\n\n        compiler : callable\n          A function with the same interface as the built-in compile(), to turn\n          the AST nodes into code objects. Default is the built-in compile().\n        result : ExecutionResult, optional\n          An object to store exceptions that occur during execution.\n\n        Returns\n        -------\n        True if an exception occurred while running code, False if it finished\n        running.\n        "
    if (not nodelist):
        return
    if (interactivity == 'last_expr_or_assign'):
        if isinstance(nodelist[(- 1)], _assign_nodes):
            asg = nodelist[(- 1)]
            if (isinstance(asg, ast.Assign) and (len(asg.targets) == 1)):
                target = asg.targets[0]
            elif isinstance(asg, _single_targets_nodes):
                target = asg.target
            else:
                target = None
            if isinstance(target, ast.Name):
                nnode = ast.Expr(ast.Name(target.id, ast.Load()))
                ast.fix_missing_locations(nnode)
                nodelist.append(nnode)
        interactivity = 'last_expr'
    _async = False
    if (interactivity == 'last_expr'):
        if isinstance(nodelist[(- 1)], ast.Expr):
            interactivity = 'last'
        else:
            interactivity = 'none'
    if (interactivity == 'none'):
        (to_run_exec, to_run_interactive) = (nodelist, [])
    elif (interactivity == 'last'):
        (to_run_exec, to_run_interactive) = (nodelist[:(- 1)], nodelist[(- 1):])
    elif (interactivity == 'all'):
        (to_run_exec, to_run_interactive) = ([], nodelist)
    else:
        raise ValueError(('Interactivity was %r' % interactivity))
    try:

        def compare(code):
            is_async = ((inspect.CO_COROUTINE & code.co_flags) == inspect.CO_COROUTINE)
            return is_async
        to_run = []
        for node in to_run_exec:
            to_run.append((node, 'exec'))
        for node in to_run_interactive:
            to_run.append((node, 'single'))
        for (node, mode) in to_run:
            if (mode == 'exec'):
                mod = Module([node], [])
            elif (mode == 'single'):
                mod = ast.Interactive([node])
            with compiler.extra_flags((getattr(ast, 'PyCF_ALLOW_TOP_LEVEL_AWAIT', 0) if self.autoawait else 0)):
                code = compiler(mod, cell_name, mode)
                code = self._update_code_co_name(code)
                asy = compare(code)
            if (await self.run_code(code, result, async_=asy)):
                return True
        if softspace(sys.stdout, 0):
            print()
    except:
        if result:
            result.error_before_exec = sys.exc_info()[1]
        self.showtraceback()
        return True
    return False
Run a sequence of AST nodes. The execution mode depends on the
interactivity parameter.

Parameters
----------
nodelist : list
  A sequence of AST nodes to run.
cell_name : str
  Will be passed to the compiler as the filename of the cell. Typically
  the value returned by ip.compile.cache(cell).
interactivity : str
  'all', 'last', 'last_expr' , 'last_expr_or_assign' or 'none',
  specifying which nodes should be run interactively (displaying output
  from expressions). 'last_expr' will run the last node interactively
  only if it is an expression (i.e. expressions in loops or other blocks
  are not displayed) 'last_expr_or_assign' will run the last expression
  or the last assignment. Other values for this parameter will raise a
  ValueError.

compiler : callable
  A function with the same interface as the built-in compile(), to turn
  the AST nodes into code objects. Default is the built-in compile().
result : ExecutionResult, optional
  An object to store exceptions that occur during execution.

Returns
-------
True if an exception occurred while running code, False if it finished
running.
async def run_ast_nodes(self, nodelist: ListType[stmt], cell_name: str, interactivity='last_expr', compiler=compile, result=None):
    "Run a sequence of AST nodes. The execution mode depends on the\n        interactivity parameter.\n\n        Parameters\n        ----------\n        nodelist : list\n          A sequence of AST nodes to run.\n        cell_name : str\n          Will be passed to the compiler as the filename of the cell. Typically\n          the value returned by ip.compile.cache(cell).\n        interactivity : str\n          'all', 'last', 'last_expr' , 'last_expr_or_assign' or 'none',\n          specifying which nodes should be run interactively (displaying output\n          from expressions). 'last_expr' will run the last node interactively\n          only if it is an expression (i.e. expressions in loops or other blocks\n          are not displayed) 'last_expr_or_assign' will run the last expression\n          or the last assignment. Other values for this parameter will raise a\n          ValueError.\n\n        compiler : callable\n          A function with the same interface as the built-in compile(), to turn\n          the AST nodes into code objects. Default is the built-in compile().\n        result : ExecutionResult, optional\n          An object to store exceptions that occur during execution.\n\n        Returns\n        -------\n        True if an exception occurred while running code, False if it finished\n        running.\n        "
    if (not nodelist):
        return
    if (interactivity == 'last_expr_or_assign'):
        if isinstance(nodelist[(- 1)], _assign_nodes):
            asg = nodelist[(- 1)]
            if (isinstance(asg, ast.Assign) and (len(asg.targets) == 1)):
                target = asg.targets[0]
            elif isinstance(asg, _single_targets_nodes):
                target = asg.target
            else:
                target = None
            if isinstance(target, ast.Name):
                nnode = ast.Expr(ast.Name(target.id, ast.Load()))
                ast.fix_missing_locations(nnode)
                nodelist.append(nnode)
        interactivity = 'last_expr'
    _async = False
    if (interactivity == 'last_expr'):
        if isinstance(nodelist[(- 1)], ast.Expr):
            interactivity = 'last'
        else:
            interactivity = 'none'
    if (interactivity == 'none'):
        (to_run_exec, to_run_interactive) = (nodelist, [])
    elif (interactivity == 'last'):
        (to_run_exec, to_run_interactive) = (nodelist[:(- 1)], nodelist[(- 1):])
    elif (interactivity == 'all'):
        (to_run_exec, to_run_interactive) = ([], nodelist)
    else:
        raise ValueError(('Interactivity was %r' % interactivity))
    try:

        def compare(code):
            is_async = ((inspect.CO_COROUTINE & code.co_flags) == inspect.CO_COROUTINE)
            return is_async
        to_run = []
        for node in to_run_exec:
            to_run.append((node, 'exec'))
        for node in to_run_interactive:
            to_run.append((node, 'single'))
        for (node, mode) in to_run:
            if (mode == 'exec'):
                mod = Module([node], [])
            elif (mode == 'single'):
                mod = ast.Interactive([node])
            with compiler.extra_flags((getattr(ast, 'PyCF_ALLOW_TOP_LEVEL_AWAIT', 0) if self.autoawait else 0)):
                code = compiler(mod, cell_name, mode)
                code = self._update_code_co_name(code)
                asy = compare(code)
            if (await self.run_code(code, result, async_=asy)):
                return True
        if softspace(sys.stdout, 0):
            print()
    except:
        if result:
            result.error_before_exec = sys.exc_info()[1]
        self.showtraceback()
        return True
    return False