def literal(value):
    """Returns a Literal instance or raise LiteralTypingError
    """
    ty = type(value)
    if isinstance(value, Literal):
        msg = "the function does not accept a Literal type; got {} ({})"
        raise ValueError(msg.format(value, ty))
    try:
        ctor = Literal.ctor_map[ty]
    except KeyError:
        raise LiteralTypingError("{} cannot be used as a literal".format(ty))
    else:
        return ctor(value)
Returns a Literal instance or raise LiteralTypingError
    
numba/core/types/misc.py