from typing import Type
from typing import Optional
from typing import List
from typing import Any
from typing import Union


def get_union_args(cls: Type) -> Optional[List[Type[Any]]]:
    """
    >>> get_union_args(Union[str, int])
    [<class 'str'>, <class 'int'>]
    >>> get_union_args(Optional[str])
    [<class 'str'>]
    """
    if getattr(cls, "__origin__", None) != Union:
        return None

    args: Type = cls.__args__
    arg_list: List[Type] = [e for e in args if e != type(None)]
    assert len(arg_list) > 0
    return arg_list