from typing import Type
from typing import Any
import typing
from typing import Union


def _is_optional(field: Type[Any]) -> bool:
    """Returns True when the given type annotation is Optional[...]."""
    return typing.get_origin(field) is Union and type(None) in typing.get_args(field)