Skip to content

Commit

Permalink
feat: un-deprecate blob.download_to_file(), bucket.create(), and buck…
Browse files Browse the repository at this point in the history
…et.list_blobs() (#1013)

Long-term plans to deprecate and remove these methods have changed.

Co-authored-by: Andrew Gorcester <gorcester@google.com>
  • Loading branch information
MiaCY and andrewsg committed Apr 27, 2023
1 parent 47228ec commit aa4f282
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 33 deletions.
2 changes: 1 addition & 1 deletion google/cloud/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ def download_to_file(
checksum="md5",
retry=DEFAULT_RETRY,
):
"""DEPRECATED. Download the contents of this blob into a file-like object.
"""Download the contents of this blob into a file-like object.
.. note::
Expand Down
16 changes: 2 additions & 14 deletions google/cloud/storage/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,10 +922,7 @@ def create(
timeout=_DEFAULT_TIMEOUT,
retry=DEFAULT_RETRY,
):
"""DEPRECATED. Creates current bucket.
.. note::
Direct use of this method is deprecated. Use ``Client.create_bucket()`` instead.
"""Creates current bucket.
If the bucket already exists, will raise
:class:`google.cloud.exceptions.Conflict`.
Expand Down Expand Up @@ -970,12 +967,6 @@ def create(
:param retry:
(Optional) How to retry the RPC. See: :ref:`configuring_retries`
"""
warnings.warn(
"Bucket.create() is deprecated and will be removed in future."
"Use Client.create_bucket() instead.",
PendingDeprecationWarning,
stacklevel=1,
)

client = self._require_client(client)
client.create_bucket(
Expand Down Expand Up @@ -1300,10 +1291,7 @@ def list_blobs(
timeout=_DEFAULT_TIMEOUT,
retry=DEFAULT_RETRY,
):
"""DEPRECATED. Return an iterator used to find blobs in the bucket.
.. note::
Direct use of this method is deprecated. Use ``Client.list_blobs`` instead.
"""Return an iterator used to find blobs in the bucket.
If :attr:`user_project` is set, bills the API request to that project.
Expand Down
20 changes: 2 additions & 18 deletions tests/unit/test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -2946,8 +2946,7 @@ def test_versioning_enabled_getter(self):
bucket = self._make_one(name=NAME, properties=before)
self.assertEqual(bucket.versioning_enabled, True)

@mock.patch("warnings.warn")
def test_create_w_defaults_deprecated(self, mock_warn):
def test_create_w_defaults(self):
bucket_name = "bucket-name"
api_response = {"name": bucket_name}
client = mock.Mock(spec=["create_bucket"])
Expand All @@ -2967,15 +2966,7 @@ def test_create_w_defaults_deprecated(self, mock_warn):
retry=DEFAULT_RETRY,
)

mock_warn.assert_called_with(
"Bucket.create() is deprecated and will be removed in future."
"Use Client.create_bucket() instead.",
PendingDeprecationWarning,
stacklevel=1,
)

@mock.patch("warnings.warn")
def test_create_w_explicit_deprecated(self, mock_warn):
def test_create_w_explicit(self):
project = "PROJECT"
location = "eu"
user_project = "USER_PROJECT"
Expand Down Expand Up @@ -3011,13 +3002,6 @@ def test_create_w_explicit_deprecated(self, mock_warn):
retry=retry,
)

mock_warn.assert_called_with(
"Bucket.create() is deprecated and will be removed in future."
"Use Client.create_bucket() instead.",
PendingDeprecationWarning,
stacklevel=1,
)

def test_versioning_enabled_setter(self):
NAME = "name"
bucket = self._make_one(name=NAME)
Expand Down

0 comments on commit aa4f282

Please sign in to comment.