def resolve_expression(
    source: str,
    arguments: Container[str],
    *,
    args_prefix: str = "__args.",
    allowed_vars: Container[str] = tuple(),
) -> str:
    """
    Validate function call and substitute references to arguments with their namespaced
    counterparts (e.g. `my_arg` => `__args.my_arg`).
    """

    root_node = parse_and_validate(source, False, "expr")
    name_nodes = _validate_nodes_and_get_names(root_node, source)

    substitutions: list[Substitution] = []
    for node in name_nodes:
        if node.id in arguments:
            substitutions.append(
                (_get_name_node_abs_range(source, node), args_prefix + node.id)
            )
        elif node.id not in _ALLOWED_BUILTINS and node.id not in allowed_vars:
            raise ExpressionParseError(
                "Invalid variable reference in expr: "
                f"{ast.get_source_segment(source, node)}"
            )

    # Prefix references to arguments with args_prefix
    return _clean_linebreaks(_apply_substitutions(source, substitutions))

    Validate function call and substitute references to arguments with their namespaced
    counterparts (e.g. `my_arg` => `__args.my_arg`).
    
poethepoet/helpers/python.py