from typing import Optional


def is_optional(t):
    """
    https://stackoverflow.com/a/62641842/4171119

    >>> is_optional(str)
    False
    >>> is_optional(Optional[str])
    True
    >>> is_optional(Union[str, None])
    True
    >>> is_optional(Union[None, str])
    True
    >>> is_optional(Union[str, None, int])
    True
    >>> is_optional(Union[str, int])
    False
    """
    return t == Optional[t]