def cast(type_name, value, **opts):
    """Convert a given string to the type indicated by ``type_name``.

    If ``None`` is passed in, it will always be returned.
    Optional arguments can include ``true_values`` and ``false_values`` to
    describe boolean types, and ``format`` for dates.
    """
    type_name, opts = _field_options(type_name, opts)
    return converter(type_name).cast(value, **opts)
Convert a given string to the type indicated by ``type_name``.

    If ``None`` is passed in, it will always be returned.
    Optional arguments can include ``true_values`` and ``false_values`` to
    describe boolean types, and ``format`` for dates.