def arg_completions(<EOL>completion_text: str,<EOL>parent_function: str,<EOL>args: list,<EOL>arg_idx: int,<EOL>bel_spec: BELSpec,<EOL>bel_fmt: str,<EOL>species_id: str,<EOL>namespace: str,<EOL>size: int,<EOL>):
function_long = bel_spec["<STR_LIT>"]["<STR_LIT>"].get(parent_function)<EOL>if not function_long:<EOL><INDENT>return []<EOL><DEDENT>signatures = bel_spec["<STR_LIT>"]["<STR_LIT>"][function_long]["<STR_LIT>"]<EOL>function_list = []<EOL>entity_types = []<EOL>fn_replace_list, ns_arg_replace_list = [], []<EOL>position_flag = False  <EOL>for signature in signatures:<EOL><INDENT>sig_arg = signature["<STR_LIT>"][arg_idx]<EOL>sig_type = sig_arg["<STR_LIT:type>"]<EOL>if sig_arg.get("<STR_LIT>", False) and arg_idx == sig_arg["<STR_LIT>"] - <NUM_LIT:1>:<EOL><INDENT>position_flag = True<EOL>if sig_type in ["<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>function_list.extend(sig_arg["<STR_LIT>"])<EOL><DEDENT>elif sig_type in ["<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>entity_types.extend(sig_arg["<STR_LIT>"])<EOL><DEDENT><DEDENT><DEDENT>if not position_flag:<EOL><INDENT>opt_fn_sig_args = []<EOL>opt_nsarg_sig_args = []<EOL>mult_fn_sig_args = []<EOL>mult_nsarg_sig_args = []<EOL>for signature in signatures:<EOL><INDENT>signature_opt_fn_sig_args = []<EOL>signature_opt_nsarg_sig_args = []<EOL>signature_mult_fn_sig_args = []<EOL>signature_mult_nsarg_sig_args = []<EOL>max_position = -<NUM_LIT:1><EOL>for sig_arg in signature["<STR_LIT>"]:<EOL><INDENT>if "<STR_LIT>" in sig_arg:<EOL><INDENT>max_position = sig_arg["<STR_LIT>"]<EOL>continue  <EOL><DEDENT>if (<EOL>sig_arg.get("<STR_LIT>", False) is True<EOL>and sig_arg.get("<STR_LIT>", False) is False<EOL>):<EOL><INDENT>if sig_arg["<STR_LIT:type>"] in ["<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>signature_opt_fn_sig_args.extend(sig_arg["<STR_LIT>"])<EOL><DEDENT>elif sig_arg["<STR_LIT:type>"] in ["<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>signature_opt_nsarg_sig_args.extend(sig_arg["<STR_LIT>"])<EOL><DEDENT><DEDENT>elif sig_arg.get("<STR_LIT>", False) is True:<EOL><INDENT>if sig_arg["<STR_LIT:type>"] in ["<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>signature_mult_fn_sig_args.extend(sig_arg["<STR_LIT>"])<EOL><DEDENT>elif sig_arg["<STR_LIT:type>"] in ["<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>signature_mult_nsarg_sig_args.extend(sig_arg["<STR_LIT>"])<EOL><DEDENT><DEDENT><DEDENT>for idx, arg in enumerate(args):<EOL><INDENT>if idx <= max_position - <NUM_LIT:1>:  <EOL><INDENT>continue<EOL><DEDENT>if idx == arg_idx:  <EOL><INDENT>continue<EOL><DEDENT>log.debug(f"<STR_LIT>")<EOL><DEDENT>opt_fn_sig_args.extend(signature_opt_fn_sig_args)<EOL>opt_nsarg_sig_args.extend(signature_opt_nsarg_sig_args)<EOL>mult_fn_sig_args.extend(signature_mult_fn_sig_args)<EOL>mult_nsarg_sig_args.extend(signature_mult_nsarg_sig_args)<EOL><DEDENT>function_list.extend(list(set(opt_fn_sig_args + mult_fn_sig_args)))<EOL>entity_types.extend(list(set(opt_nsarg_sig_args + mult_nsarg_sig_args)))<EOL><DEDENT>if function_list:<EOL><INDENT>log.debug(f"<STR_LIT>")<EOL>fn_replace_list = function_completions(<EOL>completion_text, bel_spec, function_list, bel_fmt, size<EOL>)<EOL><DEDENT>if entity_types:<EOL><INDENT>log.debug(f"<STR_LIT>")<EOL>ns_arg_replace_list = nsarg_completions(<EOL>completion_text,<EOL>entity_types,<EOL>bel_spec,<EOL>namespace,<EOL>species_id,<EOL>bel_fmt,<EOL>size,<EOL>)<EOL><DEDENT>replace_list = fn_replace_list + ns_arg_replace_list<EOL>return replace_list<EOL>
Function argument completion

    Only allow legal options for completion given function name, arguments and index of argument
    to replace.

    Args:
        completion_text: text to use for completion - used for creating highlight
        parent_function: BEL function containing these args
        args: arguments of BEL function
        arg_idx: completing on this argument identified by this index
        bel_spec: BEL Specification
        bel_fmt: short, medium, long BEL function/relation formats
        species_id: filter on this species id, e.g. TAX:9606 if available
        namespace: filter on this namespace if available
        size: number of completions to return

    Return:
        list of replacements