Skip to content

Commit 2d42731

Browse files
fix: Add async context manager return types (#732)
* fix: Add async context manager return types chore: Mock return_value should not populate oneof message fields chore: Support snippet generation for services that only support REST transport chore: Update gapic-generator-python to v1.11.0 PiperOrigin-RevId: 545430278 Source-Link: googleapis/googleapis@601b532 Source-Link: googleapis/googleapis-gen@b3f18d0 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjNmMThkMGY2NTYwYTg1NTAyMmZkMDU4ODY1ZTc2MjA0NzlkN2FmOSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent 8ce3c1a commit 2d42731

File tree

6 files changed

+25
-15
lines changed

6 files changed

+25
-15
lines changed

google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,7 @@ async def cancel_operation(
20742074
metadata=metadata,
20752075
)
20762076

2077-
async def __aenter__(self):
2077+
async def __aenter__(self) -> "FirestoreAdminAsyncClient":
20782078
return self
20792079

20802080
async def __aexit__(self, exc_type, exc, tb):

google/cloud/firestore_admin_v1/services/firestore_admin/transports/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2081,7 +2081,7 @@ def __call__(
20812081
request_kwargs = json_format.MessageToDict(request)
20822082
transcoded_request = path_template.transcode(http_options, **request_kwargs)
20832083

2084-
body = json.loads(json.dumps(transcoded_request["body"]))
2084+
body = json.dumps(transcoded_request["body"])
20852085
uri = transcoded_request["uri"]
20862086
method = transcoded_request["method"]
20872087

google/cloud/firestore_v1/services/firestore/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ async def cancel_operation(
21692169
metadata=metadata,
21702170
)
21712171

2172-
async def __aenter__(self):
2172+
async def __aenter__(self) -> "FirestoreAsyncClient":
21732173
return self
21742174

21752175
async def __aexit__(self, exc_type, exc, tb):

google/cloud/firestore_v1/services/firestore/transports/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2203,7 +2203,7 @@ def __call__(
22032203
request_kwargs = json_format.MessageToDict(request)
22042204
transcoded_request = path_template.transcode(http_options, **request_kwargs)
22052205

2206-
body = json.loads(json.dumps(transcoded_request["body"]))
2206+
body = json.dumps(transcoded_request["body"])
22072207
uri = transcoded_request["uri"]
22082208
method = transcoded_request["method"]
22092209

tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,9 +1374,11 @@ async def test_list_indexes_async_pages():
13741374
RuntimeError,
13751375
)
13761376
pages = []
1377-
async for page_ in (
1377+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1378+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1379+
async for page_ in ( # pragma: no branch
13781380
await client.list_indexes(request={})
1379-
).pages: # pragma: no branch
1381+
).pages:
13801382
pages.append(page_)
13811383
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
13821384
assert page_.raw_page.next_page_token == token
@@ -2708,9 +2710,11 @@ async def test_list_fields_async_pages():
27082710
RuntimeError,
27092711
)
27102712
pages = []
2711-
async for page_ in (
2713+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
2714+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
2715+
async for page_ in ( # pragma: no branch
27122716
await client.list_fields(request={})
2713-
).pages: # pragma: no branch
2717+
).pages:
27142718
pages.append(page_)
27152719
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
27162720
assert page_.raw_page.next_page_token == token

tests/unit/gapic/firestore_v1/test_firestore.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,9 +1178,11 @@ async def test_list_documents_async_pages():
11781178
RuntimeError,
11791179
)
11801180
pages = []
1181-
async for page_ in (
1181+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1182+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1183+
async for page_ in ( # pragma: no branch
11821184
await client.list_documents(request={})
1183-
).pages: # pragma: no branch
1185+
).pages:
11841186
pages.append(page_)
11851187
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
11861188
assert page_.raw_page.next_page_token == token
@@ -3154,9 +3156,11 @@ async def test_partition_query_async_pages():
31543156
RuntimeError,
31553157
)
31563158
pages = []
3157-
async for page_ in (
3159+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
3160+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
3161+
async for page_ in ( # pragma: no branch
31583162
await client.partition_query(request={})
3159-
).pages: # pragma: no branch
3163+
).pages:
31603164
pages.append(page_)
31613165
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
31623166
assert page_.raw_page.next_page_token == token
@@ -3742,9 +3746,11 @@ async def test_list_collection_ids_async_pages():
37423746
RuntimeError,
37433747
)
37443748
pages = []
3745-
async for page_ in (
3749+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
3750+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
3751+
async for page_ in ( # pragma: no branch
37463752
await client.list_collection_ids(request={})
3747-
).pages: # pragma: no branch
3753+
).pages:
37483754
pages.append(page_)
37493755
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
37503756
assert page_.raw_page.next_page_token == token
@@ -5150,7 +5156,7 @@ def test_batch_get_documents_rest(request_type):
51505156
# Designate an appropriate value for the returned response.
51515157
return_value = firestore.BatchGetDocumentsResponse(
51525158
transaction=b"transaction_blob",
5153-
found=document.Document(name="name_value"),
5159+
missing="missing_value",
51545160
)
51555161

51565162
# Wrap the value into a proper Response obj

0 commit comments

Comments
 (0)