Should the type hint of the attach_contents() method not be Union[str, bytes]?
attach_contents()
Union[str, bytes]