Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 92c20d3

Browse filesBrowse files
authored
fix: clarify error message and docstrings in Blob class method (#1196)
* fix: clarify error message and docstrings * run docs
1 parent a179337 commit 92c20d3
Copy full SHA for 92c20d3

File tree

Expand file treeCollapse file tree

3 files changed

+5
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+5
-4
lines changed
Open diff view settings
Collapse file

‎google/cloud/storage/blob.py‎

Copy file name to clipboardExpand all lines: google/cloud/storage/blob.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ def from_string(cls, uri, client=None):
394394
blob = Blob.from_string("gs://bucket/object", client=client)
395395
396396
:type uri: str
397-
:param uri: The blob uri pass to get blob object.
397+
:param uri: The blob uri following a gs://bucket/object pattern.
398+
Both a bucket and object name is required to construct a blob object.
398399
399400
:type client: :class:`~google.cloud.storage.client.Client`
400401
:param client:
@@ -408,7 +409,7 @@ def from_string(cls, uri, client=None):
408409

409410
match = _GS_URL_REGEX_PATTERN.match(uri)
410411
if not match:
411-
raise ValueError("URI scheme must be gs")
412+
raise ValueError("URI pattern must be gs://bucket/object")
412413
bucket = Bucket(client, name=match.group("bucket_name"))
413414
return cls(match.group("object_name"), bucket)
414415

Collapse file

‎tests/unit/test_blob.py‎

Copy file name to clipboardExpand all lines: tests/unit/test_blob.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5840,7 +5840,7 @@ def test_from_string_w_invalid_uri(self):
58405840

58415841
client = self._make_client()
58425842

5843-
with pytest.raises(ValueError, match="URI scheme must be gs"):
5843+
with pytest.raises(ValueError):
58445844
Blob.from_string("http://bucket_name/b", client)
58455845

58465846
def test_from_string_w_domain_name_bucket(self):
Collapse file

‎tests/unit/test_client.py‎

Copy file name to clipboardExpand all lines: tests/unit/test_client.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,7 @@ def test_download_blob_to_file_with_invalid_uri(self):
17501750
client = self._make_one(project=project, credentials=credentials)
17511751
file_obj = io.BytesIO()
17521752

1753-
with pytest.raises(ValueError, match="URI scheme must be gs"):
1753+
with pytest.raises(ValueError):
17541754
client.download_blob_to_file("http://bucket_name/path/to/object", file_obj)
17551755

17561756
def test_download_blob_to_file_w_no_retry(self):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.