Skip to content

Commit ee42abd

Browse files
fix: Add async context manager return types (#426)
* 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>
1 parent 9ab32bb commit ee42abd

File tree

9 files changed

+31
-19
lines changed

9 files changed

+31
-19
lines changed

google/cloud/pubsublite_v1/services/admin_service/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2510,7 +2510,7 @@ async def cancel_operation(
25102510
metadata=metadata,
25112511
)
25122512

2513-
async def __aenter__(self):
2513+
async def __aenter__(self) -> "AdminServiceAsyncClient":
25142514
return self
25152515

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

google/cloud/pubsublite_v1/services/cursor_service/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ async def cancel_operation(
740740
metadata=metadata,
741741
)
742742

743-
async def __aenter__(self):
743+
async def __aenter__(self) -> "CursorServiceAsyncClient":
744744
return self
745745

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

google/cloud/pubsublite_v1/services/partition_assignment_service/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ async def cancel_operation(
533533
metadata=metadata,
534534
)
535535

536-
async def __aenter__(self):
536+
async def __aenter__(self) -> "PartitionAssignmentServiceAsyncClient":
537537
return self
538538

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

google/cloud/pubsublite_v1/services/publisher_service/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ async def cancel_operation(
524524
metadata=metadata,
525525
)
526526

527-
async def __aenter__(self):
527+
async def __aenter__(self) -> "PublisherServiceAsyncClient":
528528
return self
529529

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

google/cloud/pubsublite_v1/services/subscriber_service/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ async def cancel_operation(
514514
metadata=metadata,
515515
)
516516

517-
async def __aenter__(self):
517+
async def __aenter__(self) -> "SubscriberServiceAsyncClient":
518518
return self
519519

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

google/cloud/pubsublite_v1/services/topic_stats_service/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ async def cancel_operation(
688688
metadata=metadata,
689689
)
690690

691-
async def __aenter__(self):
691+
async def __aenter__(self) -> "TopicStatsServiceAsyncClient":
692692
return self
693693

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

samples/generated_samples/snippet_metadata_google.cloud.pubsublite.v1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-pubsublite",
11-
"version": "1.8.2"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

tests/unit/gapic/pubsublite_v1/test_admin_service.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,9 +1810,11 @@ async def test_list_topics_async_pages():
18101810
RuntimeError,
18111811
)
18121812
pages = []
1813-
async for page_ in (
1813+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1814+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1815+
async for page_ in ( # pragma: no branch
18141816
await client.list_topics(request={})
1815-
).pages: # pragma: no branch
1817+
).pages:
18161818
pages.append(page_)
18171819
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
18181820
assert page_.raw_page.next_page_token == token
@@ -2714,9 +2716,11 @@ async def test_list_topic_subscriptions_async_pages():
27142716
RuntimeError,
27152717
)
27162718
pages = []
2717-
async for page_ in (
2719+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
2720+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
2721+
async for page_ in ( # pragma: no branch
27182722
await client.list_topic_subscriptions(request={})
2719-
).pages: # pragma: no branch
2723+
).pages:
27202724
pages.append(page_)
27212725
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
27222726
assert page_.raw_page.next_page_token == token
@@ -3654,9 +3658,11 @@ async def test_list_subscriptions_async_pages():
36543658
RuntimeError,
36553659
)
36563660
pages = []
3657-
async for page_ in (
3661+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
3662+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
3663+
async for page_ in ( # pragma: no branch
36583664
await client.list_subscriptions(request={})
3659-
).pages: # pragma: no branch
3665+
).pages:
36603666
pages.append(page_)
36613667
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
36623668
assert page_.raw_page.next_page_token == token
@@ -5238,9 +5244,11 @@ async def test_list_reservations_async_pages():
52385244
RuntimeError,
52395245
)
52405246
pages = []
5241-
async for page_ in (
5247+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
5248+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
5249+
async for page_ in ( # pragma: no branch
52425250
await client.list_reservations(request={})
5243-
).pages: # pragma: no branch
5251+
).pages:
52445252
pages.append(page_)
52455253
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
52465254
assert page_.raw_page.next_page_token == token
@@ -6174,9 +6182,11 @@ async def test_list_reservation_topics_async_pages():
61746182
RuntimeError,
61756183
)
61766184
pages = []
6177-
async for page_ in (
6185+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
6186+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
6187+
async for page_ in ( # pragma: no branch
61786188
await client.list_reservation_topics(request={})
6179-
).pages: # pragma: no branch
6189+
).pages:
61806190
pages.append(page_)
61816191
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
61826192
assert page_.raw_page.next_page_token == token

tests/unit/gapic/pubsublite_v1/test_cursor_service.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,9 +1336,11 @@ async def test_list_partition_cursors_async_pages():
13361336
RuntimeError,
13371337
)
13381338
pages = []
1339-
async for page_ in (
1339+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1340+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1341+
async for page_ in ( # pragma: no branch
13401342
await client.list_partition_cursors(request={})
1341-
).pages: # pragma: no branch
1343+
).pages:
13421344
pages.append(page_)
13431345
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
13441346
assert page_.raw_page.next_page_token == token

0 commit comments

Comments
 (0)