from typing import List
from typing import Union
from typing import Sequence


def _format_command(command: List[str], shell: bool = False) -> Union[Sequence[str], str]:
    """
    Formats a command depending on whether or not it needs to be called with a shell
    (i.e. either a list or a string).
    """
    return command if not shell else " ".join(command)