Repository: jina-ai/jina
File: jina/types/request/data.py (Python)

Code before:
    @property
    def proto_wo_data(
        self,
    ) -> Union['jina_pb2.DataRequestProtoWoData', 'jina_pb2.DataRequestProto']:
        """
        Transform the current buffer to a :class:`jina_pb2.DataRequestProtoWoData` unless the full proto has already
        been initialized or . Laziness will be broken and serialization will be recomputed when
        calling :meth:`SerializeToString`.
        :return: protobuf instance containing parameters
        """
        if self._pb_body is None:
            self._decompress_wo_data()
        return self._pb_body

    @property
    def proto(
        self,
    ) -> Union['jina_pb2.DataRequestProto', 'jina_pb2.DataRequestProtoWoData']:
        """
        Cast ``self`` to a :class:`jina_pb2.DataRequestProto`. Laziness will be broken and serialization will be recomputed when calling.
        :meth:`SerializeToString`.
        :return: DataRequestProto protobuf instance
        """
        if not self.is_decompressed:
            self._decompress()
        return self._pb_body

    @property
    def proto_with_data(
        self,
    ) -> 'jina_pb2.DataRequestProto':
        """
        Cast ``self`` to a :class:`jina_pb2.DataRequestProto`. Laziness will be broken and serialization will be recomputed when calling.
        :meth:`SerializeToString`.
        :return: DataRequestProto protobuf instance
        """
        if not self.is_decompressed_with_data:
            self._decompress()
        return self._pb_body

    def _decompress_wo_data(self):
        """Decompress the buffer into a DataRequestProto without docs, it is useful if one want to access the parameters
        or the header of the proto without the cost of deserializing the Docs."""

        # Under the hood it used a different DataRequestProto (the DataRequestProtoWoData) that will just ignore the
        # bytes from the bytes related to the docs that are store at the end of the Proto buffer
        self._pb_body = jina_pb2.DataRequestProtoWoData()
        self._pb_body.ParseFromString(self.buffer)
        self.buffer = None

    def _decompress(self):

Review comment (suggestion):
I think this could return either a proto with or without data, but the docstring doesn't match that behaviour (the type hint does, though).

Code after:
    def proto_wo_data(
        self,
    ) -> Union['jina_pb2.DataRequestProtoWoData', 'jina_pb2.DataRequestProto']:
        """
        Transform the current buffer to a :class:`jina_pb2.DataRequestProtoWoData` unless the full proto has already
        been initialized or . Laziness will be broken and serialization will be recomputed when
        calling :meth:`SerializeToString`.
        :return: protobuf instance containing parameters
        """
        if self._pb_body is None:
            self._decompress_wo_data()
        return self._pb_body

    @property
    def proto(
        self,
    ) -> Union['jina_pb2.DataRequestProto', 'jina_pb2.DataRequestProtoWoData']:
        """
        Cast ``self`` to a :class:`jina_pb2.DataRequestProto` or a :class:`jina_pb2.DataRequestProto`. Laziness will be broken and serialization will be recomputed when calling.
        it returns the underlying proto if it already exists (even if he is loaded without data) or creates a new one.
        :meth:`SerializeToString`.
        :return: DataRequestProto protobuf instance
        """
        if not self.is_decompressed:
            self._decompress()
        return self._pb_body

    @property
    def proto_with_data(
        self,
    ) -> 'jina_pb2.DataRequestProto':
        """
        Cast ``self`` to a :class:`jina_pb2.DataRequestProto`. Laziness will be broken and serialization will be recomputed when calling.
        :meth:`SerializeToString`.
        :return: DataRequestProto protobuf instance
        """
        if not self.is_decompressed_with_data:
            self._decompress()
        return self._pb_body

    def _decompress_wo_data(self):
        """Decompress the buffer into a DataRequestProto without docs, it is useful if one want to access the parameters
        or the header of the proto without the cost of deserializing the Docs."""

        # Under the hood it used a different DataRequestProto (the DataRequestProtoWoData) that will just ignore the
        # bytes from the bytes related to the docs that are store at the end of the Proto buffer
        self._pb_body = jina_pb2.DataRequestProtoWoData()
        self._pb_body.ParseFromString(self.buffer)
        self.buffer = None

    def _decompress(self):