Skip to content

Commit

Permalink
fix: Add async context manager return types (#545)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Jul 4, 2023
1 parent ec0b868 commit bc030de
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ async def sample_update_alert_policy():
# Done; return the response.
return response

async def __aenter__(self):
async def __aenter__(self) -> "AlertPolicyServiceAsyncClient":
return self

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ async def sample_list_group_members():
# Done; return the response.
return response

async def __aenter__(self):
async def __aenter__(self) -> "GroupServiceAsyncClient":
return self

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ async def sample_create_service_time_series():
metadata=metadata,
)

async def __aenter__(self):
async def __aenter__(self) -> "MetricServiceAsyncClient":
return self

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ async def sample_verify_notification_channel():
# Done; return the response.
return response

async def __aenter__(self):
async def __aenter__(self) -> "NotificationChannelServiceAsyncClient":
return self

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ async def sample_query_time_series():
# Done; return the response.
return response

async def __aenter__(self):
async def __aenter__(self) -> "QueryServiceAsyncClient":
return self

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ async def sample_delete_service_level_objective():
metadata=metadata,
)

async def __aenter__(self):
async def __aenter__(self) -> "ServiceMonitoringServiceAsyncClient":
return self

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ async def sample_update_snooze():
# Done; return the response.
return response

async def __aenter__(self):
async def __aenter__(self) -> "SnoozeServiceAsyncClient":
return self

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ async def sample_list_uptime_check_ips():
# Done; return the response.
return response

async def __aenter__(self):
async def __aenter__(self) -> "UptimeCheckServiceAsyncClient":
return self

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-monitoring",
"version": "2.15.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1150,9 +1150,11 @@ async def test_list_alert_policies_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_alert_policies(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1088,9 +1088,11 @@ async def test_list_groups_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_groups(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down Expand Up @@ -2500,9 +2502,11 @@ async def test_list_group_members_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_group_members(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1137,9 +1137,11 @@ async def test_list_monitored_resource_descriptors_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_monitored_resource_descriptors(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down Expand Up @@ -1843,9 +1845,11 @@ async def test_list_metric_descriptors_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_metric_descriptors(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down Expand Up @@ -3100,9 +3104,11 @@ async def test_list_time_series_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_time_series(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1181,9 +1181,11 @@ async def test_list_notification_channel_descriptors_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_notification_channel_descriptors(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down Expand Up @@ -1895,9 +1897,11 @@ async def test_list_notification_channels_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_notification_channels(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,9 +1020,11 @@ async def test_query_time_series_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.query_time_series(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,6 @@ def test_create_service(request_type, transport: str = "grpc"):
call.return_value = gm_service.Service(
name="name_value",
display_name="display_name_value",
custom=None,
)
response = client.create_service(request)

Expand Down Expand Up @@ -989,7 +988,6 @@ def test_get_service(request_type, transport: str = "grpc"):
call.return_value = service.Service(
name="name_value",
display_name="display_name_value",
custom=None,
)
response = client.get_service(request)

Expand Down Expand Up @@ -1611,9 +1609,11 @@ async def test_list_services_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_services(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down Expand Up @@ -1642,7 +1642,6 @@ def test_update_service(request_type, transport: str = "grpc"):
call.return_value = gm_service.Service(
name="name_value",
display_name="display_name_value",
custom=None,
)
response = client.update_service(request)

Expand Down Expand Up @@ -2098,7 +2097,7 @@ def test_create_service_level_objective(request_type, transport: str = "grpc"):
name="name_value",
display_name="display_name_value",
goal=0.419,
rolling_period=duration_pb2.Duration(seconds=751),
calendar_period=calendar_period_pb2.CalendarPeriod.DAY,
)
response = client.create_service_level_objective(request)

Expand Down Expand Up @@ -2364,7 +2363,7 @@ def test_get_service_level_objective(request_type, transport: str = "grpc"):
name="name_value",
display_name="display_name_value",
goal=0.419,
rolling_period=duration_pb2.Duration(seconds=751),
calendar_period=calendar_period_pb2.CalendarPeriod.DAY,
)
response = client.get_service_level_objective(request)

Expand Down Expand Up @@ -3029,9 +3028,11 @@ async def test_list_service_level_objectives_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_service_level_objectives(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down Expand Up @@ -3063,7 +3064,7 @@ def test_update_service_level_objective(request_type, transport: str = "grpc"):
name="name_value",
display_name="display_name_value",
goal=0.419,
rolling_period=duration_pb2.Duration(seconds=751),
calendar_period=calendar_period_pb2.CalendarPeriod.DAY,
)
response = client.update_service_level_objective(request)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1343,9 +1343,11 @@ async def test_list_snoozes_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_snoozes(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1146,9 +1146,11 @@ async def test_list_uptime_check_configs_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_uptime_check_configs(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down Expand Up @@ -1182,12 +1184,6 @@ def test_get_uptime_check_config(request_type, transport: str = "grpc"):
checker_type=uptime.UptimeCheckConfig.CheckerType.STATIC_IP_CHECKERS,
selected_regions=[uptime.UptimeCheckRegion.USA],
is_internal=True,
monitored_resource=monitored_resource_pb2.MonitoredResource(
type="type_value"
),
http_check=uptime.UptimeCheckConfig.HttpCheck(
request_method=uptime.UptimeCheckConfig.HttpCheck.RequestMethod.GET
),
)
response = client.get_uptime_check_config(request)

Expand Down Expand Up @@ -1455,12 +1451,6 @@ def test_create_uptime_check_config(request_type, transport: str = "grpc"):
checker_type=uptime.UptimeCheckConfig.CheckerType.STATIC_IP_CHECKERS,
selected_regions=[uptime.UptimeCheckRegion.USA],
is_internal=True,
monitored_resource=monitored_resource_pb2.MonitoredResource(
type="type_value"
),
http_check=uptime.UptimeCheckConfig.HttpCheck(
request_method=uptime.UptimeCheckConfig.HttpCheck.RequestMethod.GET
),
)
response = client.create_uptime_check_config(request)

Expand Down Expand Up @@ -1738,12 +1728,6 @@ def test_update_uptime_check_config(request_type, transport: str = "grpc"):
checker_type=uptime.UptimeCheckConfig.CheckerType.STATIC_IP_CHECKERS,
selected_regions=[uptime.UptimeCheckRegion.USA],
is_internal=True,
monitored_resource=monitored_resource_pb2.MonitoredResource(
type="type_value"
),
http_check=uptime.UptimeCheckConfig.HttpCheck(
request_method=uptime.UptimeCheckConfig.HttpCheck.RequestMethod.GET
),
)
response = client.update_uptime_check_config(request)

Expand Down Expand Up @@ -2499,9 +2483,11 @@ async def test_list_uptime_check_ips_async_pages():
RuntimeError,
)
pages = []
async for page_ in (
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
async for page_ in ( # pragma: no branch
await client.list_uptime_check_ips(request={})
).pages: # pragma: no branch
).pages:
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down

0 comments on commit bc030de

Please sign in to comment.