from typing import get_origin
from typing import Literal


def is_literal_type(tp: type) -> bool:
    """
    Test if the given type is a literal expression.
    """
    # Stolen from typing_inspect
    origin = get_origin(tp)
    return tp is Literal or origin is Literal