def METHOD_NAME(self, data: Union[bytes, str]) -> int:
    """Write `data` to the secure temporary file. This method may be
    called any number of times following instance initialization,
    but after calling :meth:`read`, you cannot write to the file
    again.
    """
    if self.last_action == "read":
        raise AssertionError("You cannot write after reading!")
    self.last_action = "write"
    if isinstance(data, str):
        data_as_bytes = data.encode("utf-8")
    else:
        data_as_bytes = data
    return self.file.METHOD_NAME(self.encryptor.update(data_as_bytes))