def METHOD_NAME(annotation: T) -> T:
    """Strips 'Optional' from 'Optional[<type>]' if applicable.
    For example::
      Optional[str] -> str
      str -> str
      List[int] -> List[int]
    Args:
      annotation: The original type annotation which may or may not has
        `Optional`.
    Returns:
      The type inside Optional[] if Optional exists, otherwise the original type.
    """
    if getattr(annotation, '__origin__',
               None) is Union and annotation.__args__[1] is type(None):
        return annotation.__args__[0]
    return annotation