from typing import Union


def coerce_to_bytes(thing: Union[str, bytes]) -> bytes:
    """
    Ensure whatever is passed in is a bytes object.
    """
    return thing.encode('UTF-8') if isinstance(thing, str) else thing