Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage: Blob.delete returns self.bucket.delete_blob but delete_blob returns nothing #9985

Closed
sheiun opened this issue Dec 17, 2019 · 0 comments · Fixed by #10015
Closed
Assignees
Labels
api: storage Issues related to the Cloud Storage API. type: docs Improvement to the documentation for an API.

Comments

@sheiun
Copy link

sheiun commented Dec 17, 2019

Description

In this function docs returns part says returns The blob that was just deleted. but actually self.bucket.delete_blob didn't return anything and rtype also not Blob but None.

I'm not sure the fault is that Blob.delete return unnecessary or Bucket.delete_blob didn't return after blob api_request.

Blob

https://github.com/googleapis/google-cloud-python/blob/master/storage/google/cloud/storage/blob.py#L548

    def delete(self, client=None):
        """Deletes a blob from Cloud Storage.
        If :attr:`user_project` is set on the bucket, bills the API request
        to that project.
        :type client: :class:`~google.cloud.storage.client.Client` or
                      ``NoneType``
        :param client: Optional. The client to use.  If not passed, falls back
                       to the ``client`` stored on the blob's bucket.
        :rtype: :class:`Blob`
        :returns: The blob that was just deleted.
        :raises: :class:`google.cloud.exceptions.NotFound`
                 (propagated from
                 :meth:`google.cloud.storage.bucket.Bucket.delete_blob`).
        """
        return self.bucket.delete_blob(
            self.name, client=client, generation=self.generation
        )

Bucket

https://github.com/googleapis/google-cloud-python/blob/master/storage/google/cloud/storage/bucket.py#L1055

    def delete_blob(self, blob_name, client=None, generation=None):
        """Deletes a blob from the current bucket.
        If the blob isn't found (backend 404), raises a
        :class:`google.cloud.exceptions.NotFound`.
        For example:
        .. literalinclude:: snippets.py
          :start-after: [START delete_blob]
          :end-before: [END delete_blob]
        If :attr:`user_project` is set, bills the API request to that project.
        :type blob_name: str
        :param blob_name: A blob name to delete.
        :type client: :class:`~google.cloud.storage.client.Client` or
                      ``NoneType``
        :param client: Optional. The client to use.  If not passed, falls back
                       to the ``client`` stored on the current bucket.
        :type generation: long
        :param generation: Optional. If present, permanently deletes a specific
                           revision of this object.
        :raises: :class:`google.cloud.exceptions.NotFound` (to suppress
                 the exception, call ``delete_blobs``, passing a no-op
                 ``on_error`` callback, e.g.:
        .. literalinclude:: snippets.py
            :start-after: [START delete_blobs]
            :end-before: [END delete_blobs]
        """
        client = self._require_client(client)
        blob = Blob(blob_name, bucket=self, generation=generation)

        # We intentionally pass `_target_object=None` since a DELETE
        # request has no response value (whether in a standard request or
        # in a batch request).
        client._connection.api_request(
            method="DELETE",
            path=blob.path,
            query_params=blob._query_params,
            _target_object=None,
        )
@HemangChothani HemangChothani added api: storage Issues related to the Cloud Storage API. type: docs Improvement to the documentation for an API. labels Dec 17, 2019
@HemangChothani HemangChothani self-assigned this Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. type: docs Improvement to the documentation for an API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants