from typing import Optional
from typing import Type


def innermost_type(cls: Optional[Type]) -> Type:
    """Return the innermost type from a potentially nested type.

    >>> innermost_type(str)
    <class 'str'>
    >>> innermost_type(List[str])
    <class 'str'>
    >>> innermost_type(Optional[List[str]])
    <class 'str'>
    >>> innermost_type(None)
    <class 'NoneType'>
    """
    if cls is None:
        return type(None)
    inner = cls
    while getattr(inner, "__args__", None):
        inner = inner.__args__[0]
    return inner