from typing import Union


def _IsOptionalType(cls: type, base: type) -> bool:
    """If the cls looks like a base or Optional[base] type."""
    if issubclass(cls, base):
        return True
    return (hasattr(cls, '__origin__')
            # pylint: disable=comparison-with-callable
            and cls.__origin__ == Union and len(cls.__args__) == 2
            and issubclass(cls.__args__[0], base)
            and cls.__args__[1] == type(None))