from typing import Union


def as_str(v: Union[bytes, str]) -> str:
    """Force to a str."""

    if isinstance(v, bytes):
        return v.decode("utf-8")
    elif isinstance(v, str):
        return v
    else:
        raise TypeError("Unable to str-coerce " + str(type(v)))