Skip to content

Commit 7e2e712

Browse files
fix: Add async context manager return types (#967)
* 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 fdba701 commit 7e2e712

File tree

9 files changed

+42
-24
lines changed

9 files changed

+42
-24
lines changed

google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3272,7 +3272,7 @@ async def cancel_operation(
32723272
metadata=metadata,
32733273
)
32743274

3275-
async def __aenter__(self):
3275+
async def __aenter__(self) -> "DatabaseAdminAsyncClient":
32763276
return self
32773277

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

google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2303,7 +2303,7 @@ async def sample_test_iam_permissions():
23032303
# Done; return the response.
23042304
return response
23052305

2306-
async def __aenter__(self):
2306+
async def __aenter__(self) -> "InstanceAdminAsyncClient":
23072307
return self
23082308

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

google/cloud/spanner_v1/services/spanner/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@ async def sample_partition_read():
19711971
# Done; return the response.
19721972
return response
19731973

1974-
async def __aenter__(self):
1974+
async def __aenter__(self) -> "SpannerAsyncClient":
19751975
return self
19761976

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

samples/generated_samples/snippet_metadata_google.spanner.admin.database.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-spanner-admin-database",
11-
"version": "3.36.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

samples/generated_samples/snippet_metadata_google.spanner.admin.instance.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-spanner-admin-instance",
11-
"version": "3.36.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

samples/generated_samples/snippet_metadata_google.spanner.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-spanner",
11-
"version": "3.36.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,9 +1142,11 @@ async def test_list_databases_async_pages():
11421142
RuntimeError,
11431143
)
11441144
pages = []
1145-
async for page_ in (
1145+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1146+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1147+
async for page_ in ( # pragma: no branch
11461148
await client.list_databases(request={})
1147-
).pages: # pragma: no branch
1149+
).pages:
11481150
pages.append(page_)
11491151
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
11501152
assert page_.raw_page.next_page_token == token
@@ -5009,9 +5011,11 @@ async def test_list_backups_async_pages():
50095011
RuntimeError,
50105012
)
50115013
pages = []
5012-
async for page_ in (
5014+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
5015+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
5016+
async for page_ in ( # pragma: no branch
50135017
await client.list_backups(request={})
5014-
).pages: # pragma: no branch
5018+
).pages:
50155019
pages.append(page_)
50165020
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
50175021
assert page_.raw_page.next_page_token == token
@@ -5695,9 +5699,11 @@ async def test_list_database_operations_async_pages():
56955699
RuntimeError,
56965700
)
56975701
pages = []
5698-
async for page_ in (
5702+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
5703+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
5704+
async for page_ in ( # pragma: no branch
56995705
await client.list_database_operations(request={})
5700-
).pages: # pragma: no branch
5706+
).pages:
57015707
pages.append(page_)
57025708
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
57035709
assert page_.raw_page.next_page_token == token
@@ -6137,9 +6143,11 @@ async def test_list_backup_operations_async_pages():
61376143
RuntimeError,
61386144
)
61396145
pages = []
6140-
async for page_ in (
6146+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
6147+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
6148+
async for page_ in ( # pragma: no branch
61416149
await client.list_backup_operations(request={})
6142-
).pages: # pragma: no branch
6150+
).pages:
61436151
pages.append(page_)
61446152
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
61456153
assert page_.raw_page.next_page_token == token
@@ -6582,9 +6590,11 @@ async def test_list_database_roles_async_pages():
65826590
RuntimeError,
65836591
)
65846592
pages = []
6585-
async for page_ in (
6593+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
6594+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
6595+
async for page_ in ( # pragma: no branch
65866596
await client.list_database_roles(request={})
6587-
).pages: # pragma: no branch
6597+
).pages:
65886598
pages.append(page_)
65896599
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
65906600
assert page_.raw_page.next_page_token == token

tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,9 +1162,11 @@ async def test_list_instance_configs_async_pages():
11621162
RuntimeError,
11631163
)
11641164
pages = []
1165-
async for page_ in (
1165+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1166+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1167+
async for page_ in ( # pragma: no branch
11661168
await client.list_instance_configs(request={})
1167-
).pages: # pragma: no branch
1169+
).pages:
11681170
pages.append(page_)
11691171
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
11701172
assert page_.raw_page.next_page_token == token
@@ -2639,9 +2641,11 @@ async def test_list_instance_config_operations_async_pages():
26392641
RuntimeError,
26402642
)
26412643
pages = []
2642-
async for page_ in (
2644+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
2645+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
2646+
async for page_ in ( # pragma: no branch
26432647
await client.list_instance_config_operations(request={})
2644-
).pages: # pragma: no branch
2648+
).pages:
26452649
pages.append(page_)
26462650
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
26472651
assert page_.raw_page.next_page_token == token
@@ -3060,9 +3064,11 @@ async def test_list_instances_async_pages():
30603064
RuntimeError,
30613065
)
30623066
pages = []
3063-
async for page_ in (
3067+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
3068+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
3069+
async for page_ in ( # pragma: no branch
30643070
await client.list_instances(request={})
3065-
).pages: # pragma: no branch
3071+
).pages:
30663072
pages.append(page_)
30673073
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
30683074
assert page_.raw_page.next_page_token == token

tests/unit/gapic/spanner_v1/test_spanner.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,9 +1799,11 @@ async def test_list_sessions_async_pages():
17991799
RuntimeError,
18001800
)
18011801
pages = []
1802-
async for page_ in (
1802+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1803+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1804+
async for page_ in ( # pragma: no branch
18031805
await client.list_sessions(request={})
1804-
).pages: # pragma: no branch
1806+
).pages:
18051807
pages.append(page_)
18061808
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
18071809
assert page_.raw_page.next_page_token == token

0 commit comments

Comments
 (0)