from typing import Any
from typing import Optional
from typing import Tuple
from typing import Type
from typing import Union


def _union_args(cls: Any) -> Optional[Tuple[Type]]:
    """Convert ``Union[T1, T2]`` to (T1, T2).

    Returns ``None`` if `cls` is not a specific :class:`typing.Union` type.
    """
    if not isinstance(cls, type(Union[int, float])):
        return None
    try:
        # Python 3.5.3 onwards
        args = cls.__args__  # type: ignore
    except AttributeError:
        args = cls.__union_params__  # type: ignore
    return args