from typing import Any
import ast


def literal_eval(val) -> Any:
    """ Converts a string literal to python object. """
    try:
        return ast.literal_eval(val)
    except (SyntaxError, ValueError):
        return val