def METHOD_NAME(string_or_bytes: str | bytes) -> bytes:
    """Encode a string to bytes, if it isn't already.
    :param string_or_bytes: The string to encode.
        Does nothing if it's already bytes.
    """
    # from pysecurity
    if isinstance(string_or_bytes, str):
        return string_or_bytes.encode()
    else:
        return string_or_bytes