from typing import Optional
from typing import Union
from typing import List
from typing import Set
from typing import Tuple


def enforce_list(scope: Optional[Union[str, List, Set, Tuple]]) -> List:
    """
    Converts a space separated string to a list of scopes.

    Note:
        If an iterable is passed to this method it will return a list
        representation of the iterable. Use :py:func:`enforce_str` to
        convert iterables to a scope string.
    Args:
        scope: An iterable or string that contains scopes.
    Returns:
        A list of scopes.
    Raises:
        TypeError: The ``scope`` value passed is not of the proper type.
    """
    if isinstance(scope, (tuple, list, set)):
        return [str(s) for s in scope]
    elif scope is None:
        return []
    else:
        return scope.strip().split(" ")