from typing import Sequence
from typing import Union
import shlex


def command_strings_to_lists(
    cmds: Sequence[Union[str, Sequence[str]]]
) -> Sequence[Sequence[str]]:
    """
    Convert any command strings in `cmds` to lists.

    Args:
        cmds: Commands - either strings or lists of arguments.

    Returns:
        A sequence of command argument sequences.
    """
    return [shlex.split(cmd) if isinstance(cmd, str) else cmd for cmd in cmds]