from typing import Union


def _get_optional_type(type_):
    """Check if a type is an ``Union`` permitting ``None``.

    For ``Optional``-like unions permitting only ``None`` and another type, returns the other type. For other
    ``None``-permitting unions, returns ``True``. For everything else, returns ``False``.
    """
    try:
        # get origin and args, raise AttributeError if missing
        origin = type_.__origin__
        args = tuple(type_.__args__)
        # ensure we're dealing with Optional/Union
        if origin != Union:
            return False
        # for Union[Some, None] return Some, raise ValueError if no None
        none_pos = args.index(type(None))
        if len(args) == 2:
            return args[1 - none_pos]
        # can't return a concrete type
        return True
    except (AttributeError, ValueError):
        return False