def flatten_args(args: list, join=False, *, empty=(None, [], (), '')) -> list:
    """Flatten args and remove empty items.

    Args:
        args: A list of items (typically but not necessarily strings),
            which may contain sub-lists, that will be flattened into
            a single list with empty items removed. Empty items include
            ``None`` and empty lists, tuples, and strings.
        join: If ``True`` or a string, the final flattened list will be
            joined into a single string. The default join string is
            a space.
        empty: Items that are considered empty.

    Returns:
        list|str: The list of args flattened with empty items removed
            and the remaining items converted to strings. If ``join`` is
            specified, the list of flattened args will be joined into
            a single string.

    Examples::

        >>> flatten_args([])
        []
        >>> flatten_args(())
        []
        >>> flatten_args([(), (), [(), ()]])
        []
        >>> flatten_args(['executable', '--flag' if True else None, ('--option', 'value'), [None]])
        ['executable', '--flag', '--option', 'value']
        >>> flatten_args(['executable', '--option', 0])
        ['executable', '--option', '0']

    """
    flat_args = []
    non_empty_args = (arg for arg in args if arg not in empty)
    for arg in non_empty_args:
        if isinstance(arg, (list, tuple)):
            flat_args.extend(flatten_args(arg))
        else:
            flat_args.append(str(arg))
    if join:
        join = ' ' if join is True else join
        flat_args = join.join(flat_args)
    return flat_args
Flatten args and remove empty items.

    Args:
        args: A list of items (typically but not necessarily strings),
            which may contain sub-lists, that will be flattened into
            a single list with empty items removed. Empty items include
            ``None`` and empty lists, tuples, and strings.
        join: If ``True`` or a string, the final flattened list will be
            joined into a single string. The default join string is
            a space.
        empty: Items that are considered empty.

    Returns:
        list|str: The list of args flattened with empty items removed
            and the remaining items converted to strings. If ``join`` is
            specified, the list of flattened args will be joined into
            a single string.

    Examples::

        >>> flatten_args([])
        []
        >>> flatten_args(())
        []
        >>> flatten_args([(), (), [(), ()]])
        []
        >>> flatten_args(['executable', '--flag' if True else None, ('--option', 'value'), [None]])
        ['executable', '--flag', '--option', 'value']
        >>> flatten_args(['executable', '--option', 0])
        ['executable', '--option', '0']