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

fix: un-deprecate blob.download_to_file() and bucket methods #1013

Merged
merged 3 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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