def write(self, keyset: tink_pb2.Keyset) -> None: if not isinstance(keyset, tink_pb2.Keyset): raise tink_error.TinkError('invalid keyset.') self._io_stream.write(keyset.SerializeToString()) self._io_stream.flush()