from typing import Union


def cast_to(type_hint, value) -> Union[str, float, int]:
    """Cast a value to the corresponding type_hint.

    If it fails, it will give a ValueError.

    Args:
        type_hint ([type]): The desired final type.
        value : Value to be casted into the desired final type.

    Returns:
        Union[str, float, int]: The value in the corresponding type.
    """    
    if type_hint == 'float':
        value = float(value)
    elif type_hint == 'int':
        value = int(value)
    return value