from typing import Union


def type_looks_optional(annotation):
    """Return True if annotation looks like it was created with Optional"""
    # Optional is just an alias for Union[NoneType, <type>] and this information
    # is lost by the time we can inspect the annoation
    if hasattr(annotation, "__origin__") and annotation.__origin__ is Union and type(None) in annotation.__args__:
        return True
    return False