Skip to content
This repository was archived by the owner on Dec 31, 2023. It is now read-only.

Commit 4309faa

Browse files
fix: Add async context manager return types (#545)
* 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: https://github.com/googleapis/googleapis-gen/commit/b3f18d0f6560a855022fd058865e7620479d7af9 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 a318b25 commit 4309faa

File tree

17 files changed

+68
-61
lines changed

17 files changed

+68
-61
lines changed

google/cloud/monitoring_v3/services/alert_policy_service/async_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ async def sample_update_alert_policy():
868868
# Done; return the response.
869869
return response
870870

871-
async def __aenter__(self):
871+
async def __aenter__(self) -> "AlertPolicyServiceAsyncClient":
872872
return self
873873

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

google/cloud/monitoring_v3/services/group_service/async_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ async def sample_list_group_members():
10171017
# Done; return the response.
10181018
return response
10191019

1020-
async def __aenter__(self):
1020+
async def __aenter__(self) -> "GroupServiceAsyncClient":
10211021
return self
10221022

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

google/cloud/monitoring_v3/services/metric_service/async_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ async def sample_create_service_time_series():
13861386
metadata=metadata,
13871387
)
13881388

1389-
async def __aenter__(self):
1389+
async def __aenter__(self) -> "MetricServiceAsyncClient":
13901390
return self
13911391

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

google/cloud/monitoring_v3/services/notification_channel_service/async_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ async def sample_verify_notification_channel():
15191519
# Done; return the response.
15201520
return response
15211521

1522-
async def __aenter__(self):
1522+
async def __aenter__(self) -> "NotificationChannelServiceAsyncClient":
15231523
return self
15241524

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

google/cloud/monitoring_v3/services/query_service/async_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ async def sample_query_time_series():
304304
# Done; return the response.
305305
return response
306306

307-
async def __aenter__(self):
307+
async def __aenter__(self) -> "QueryServiceAsyncClient":
308308
return self
309309

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

google/cloud/monitoring_v3/services/service_monitoring_service/async_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ async def sample_delete_service_level_objective():
14161416
metadata=metadata,
14171417
)
14181418

1419-
async def __aenter__(self):
1419+
async def __aenter__(self) -> "ServiceMonitoringServiceAsyncClient":
14201420
return self
14211421

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

google/cloud/monitoring_v3/services/snooze_service/async_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ async def sample_update_snooze():
763763
# Done; return the response.
764764
return response
765765

766-
async def __aenter__(self):
766+
async def __aenter__(self) -> "SnoozeServiceAsyncClient":
767767
return self
768768

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

google/cloud/monitoring_v3/services/uptime_check_service/async_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ async def sample_list_uptime_check_ips():
921921
# Done; return the response.
922922
return response
923923

924-
async def __aenter__(self):
924+
async def __aenter__(self) -> "UptimeCheckServiceAsyncClient":
925925
return self
926926

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

samples/generated_samples/snippet_metadata_google.monitoring.v3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-monitoring",
11-
"version": "2.15.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

tests/unit/gapic/monitoring_v3/test_alert_policy_service.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1150,9 +1150,11 @@ async def test_list_alert_policies_async_pages():
11501150
RuntimeError,
11511151
)
11521152
pages = []
1153-
async for page_ in (
1153+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1154+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1155+
async for page_ in ( # pragma: no branch
11541156
await client.list_alert_policies(request={})
1155-
).pages: # pragma: no branch
1157+
).pages:
11561158
pages.append(page_)
11571159
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
11581160
assert page_.raw_page.next_page_token == token

tests/unit/gapic/monitoring_v3/test_group_service.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -1088,9 +1088,11 @@ async def test_list_groups_async_pages():
10881088
RuntimeError,
10891089
)
10901090
pages = []
1091-
async for page_ in (
1091+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1092+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1093+
async for page_ in ( # pragma: no branch
10921094
await client.list_groups(request={})
1093-
).pages: # pragma: no branch
1095+
).pages:
10941096
pages.append(page_)
10951097
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
10961098
assert page_.raw_page.next_page_token == token
@@ -2500,9 +2502,11 @@ async def test_list_group_members_async_pages():
25002502
RuntimeError,
25012503
)
25022504
pages = []
2503-
async for page_ in (
2505+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
2506+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
2507+
async for page_ in ( # pragma: no branch
25042508
await client.list_group_members(request={})
2505-
).pages: # pragma: no branch
2509+
).pages:
25062510
pages.append(page_)
25072511
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
25082512
assert page_.raw_page.next_page_token == token

tests/unit/gapic/monitoring_v3/test_metric_service.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -1137,9 +1137,11 @@ async def test_list_monitored_resource_descriptors_async_pages():
11371137
RuntimeError,
11381138
)
11391139
pages = []
1140-
async for page_ in (
1140+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1141+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1142+
async for page_ in ( # pragma: no branch
11411143
await client.list_monitored_resource_descriptors(request={})
1142-
).pages: # pragma: no branch
1144+
).pages:
11431145
pages.append(page_)
11441146
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
11451147
assert page_.raw_page.next_page_token == token
@@ -1843,9 +1845,11 @@ async def test_list_metric_descriptors_async_pages():
18431845
RuntimeError,
18441846
)
18451847
pages = []
1846-
async for page_ in (
1848+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1849+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1850+
async for page_ in ( # pragma: no branch
18471851
await client.list_metric_descriptors(request={})
1848-
).pages: # pragma: no branch
1852+
).pages:
18491853
pages.append(page_)
18501854
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
18511855
assert page_.raw_page.next_page_token == token
@@ -3100,9 +3104,11 @@ async def test_list_time_series_async_pages():
31003104
RuntimeError,
31013105
)
31023106
pages = []
3103-
async for page_ in (
3107+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
3108+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
3109+
async for page_ in ( # pragma: no branch
31043110
await client.list_time_series(request={})
3105-
).pages: # pragma: no branch
3111+
).pages:
31063112
pages.append(page_)
31073113
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
31083114
assert page_.raw_page.next_page_token == token

tests/unit/gapic/monitoring_v3/test_notification_channel_service.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -1181,9 +1181,11 @@ async def test_list_notification_channel_descriptors_async_pages():
11811181
RuntimeError,
11821182
)
11831183
pages = []
1184-
async for page_ in (
1184+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1185+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1186+
async for page_ in ( # pragma: no branch
11851187
await client.list_notification_channel_descriptors(request={})
1186-
).pages: # pragma: no branch
1188+
).pages:
11871189
pages.append(page_)
11881190
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
11891191
assert page_.raw_page.next_page_token == token
@@ -1895,9 +1897,11 @@ async def test_list_notification_channels_async_pages():
18951897
RuntimeError,
18961898
)
18971899
pages = []
1898-
async for page_ in (
1900+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1901+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1902+
async for page_ in ( # pragma: no branch
18991903
await client.list_notification_channels(request={})
1900-
).pages: # pragma: no branch
1904+
).pages:
19011905
pages.append(page_)
19021906
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
19031907
assert page_.raw_page.next_page_token == token

tests/unit/gapic/monitoring_v3/test_query_service.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1020,9 +1020,11 @@ async def test_query_time_series_async_pages():
10201020
RuntimeError,
10211021
)
10221022
pages = []
1023-
async for page_ in (
1023+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1024+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1025+
async for page_ in ( # pragma: no branch
10241026
await client.query_time_series(request={})
1025-
).pages: # pragma: no branch
1027+
).pages:
10261028
pages.append(page_)
10271029
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
10281030
assert page_.raw_page.next_page_token == token

tests/unit/gapic/monitoring_v3/test_service_monitoring_service.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,6 @@ def test_create_service(request_type, transport: str = "grpc"):
746746
call.return_value = gm_service.Service(
747747
name="name_value",
748748
display_name="display_name_value",
749-
custom=None,
750749
)
751750
response = client.create_service(request)
752751

@@ -989,7 +988,6 @@ def test_get_service(request_type, transport: str = "grpc"):
989988
call.return_value = service.Service(
990989
name="name_value",
991990
display_name="display_name_value",
992-
custom=None,
993991
)
994992
response = client.get_service(request)
995993

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

@@ -2098,7 +2097,7 @@ def test_create_service_level_objective(request_type, transport: str = "grpc"):
20982097
name="name_value",
20992098
display_name="display_name_value",
21002099
goal=0.419,
2101-
rolling_period=duration_pb2.Duration(seconds=751),
2100+
calendar_period=calendar_period_pb2.CalendarPeriod.DAY,
21022101
)
21032102
response = client.create_service_level_objective(request)
21042103

@@ -2364,7 +2363,7 @@ def test_get_service_level_objective(request_type, transport: str = "grpc"):
23642363
name="name_value",
23652364
display_name="display_name_value",
23662365
goal=0.419,
2367-
rolling_period=duration_pb2.Duration(seconds=751),
2366+
calendar_period=calendar_period_pb2.CalendarPeriod.DAY,
23682367
)
23692368
response = client.get_service_level_objective(request)
23702369

@@ -3029,9 +3028,11 @@ async def test_list_service_level_objectives_async_pages():
30293028
RuntimeError,
30303029
)
30313030
pages = []
3032-
async for page_ in (
3031+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
3032+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
3033+
async for page_ in ( # pragma: no branch
30333034
await client.list_service_level_objectives(request={})
3034-
).pages: # pragma: no branch
3035+
).pages:
30353036
pages.append(page_)
30363037
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
30373038
assert page_.raw_page.next_page_token == token
@@ -3063,7 +3064,7 @@ def test_update_service_level_objective(request_type, transport: str = "grpc"):
30633064
name="name_value",
30643065
display_name="display_name_value",
30653066
goal=0.419,
3066-
rolling_period=duration_pb2.Duration(seconds=751),
3067+
calendar_period=calendar_period_pb2.CalendarPeriod.DAY,
30673068
)
30683069
response = client.update_service_level_objective(request)
30693070

tests/unit/gapic/monitoring_v3/test_snooze_service.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1343,9 +1343,11 @@ async def test_list_snoozes_async_pages():
13431343
RuntimeError,
13441344
)
13451345
pages = []
1346-
async for page_ in (
1346+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1347+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1348+
async for page_ in ( # pragma: no branch
13471349
await client.list_snoozes(request={})
1348-
).pages: # pragma: no branch
1350+
).pages:
13491351
pages.append(page_)
13501352
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
13511353
assert page_.raw_page.next_page_token == token

tests/unit/gapic/monitoring_v3/test_uptime_check_service.py

+8-22
Original file line numberDiff line numberDiff line change
@@ -1146,9 +1146,11 @@ async def test_list_uptime_check_configs_async_pages():
11461146
RuntimeError,
11471147
)
11481148
pages = []
1149-
async for page_ in (
1149+
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
1150+
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
1151+
async for page_ in ( # pragma: no branch
11501152
await client.list_uptime_check_configs(request={})
1151-
).pages: # pragma: no branch
1153+
).pages:
11521154
pages.append(page_)
11531155
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
11541156
assert page_.raw_page.next_page_token == token
@@ -1182,12 +1184,6 @@ def test_get_uptime_check_config(request_type, transport: str = "grpc"):
11821184
checker_type=uptime.UptimeCheckConfig.CheckerType.STATIC_IP_CHECKERS,
11831185
selected_regions=[uptime.UptimeCheckRegion.USA],
11841186
is_internal=True,
1185-
monitored_resource=monitored_resource_pb2.MonitoredResource(
1186-
type="type_value"
1187-
),
1188-
http_check=uptime.UptimeCheckConfig.HttpCheck(
1189-
request_method=uptime.UptimeCheckConfig.HttpCheck.RequestMethod.GET
1190-
),
11911187
)
11921188
response = client.get_uptime_check_config(request)
11931189

@@ -1455,12 +1451,6 @@ def test_create_uptime_check_config(request_type, transport: str = "grpc"):
14551451
checker_type=uptime.UptimeCheckConfig.CheckerType.STATIC_IP_CHECKERS,
14561452
selected_regions=[uptime.UptimeCheckRegion.USA],
14571453
is_internal=True,
1458-
monitored_resource=monitored_resource_pb2.MonitoredResource(
1459-
type="type_value"
1460-
),
1461-
http_check=uptime.UptimeCheckConfig.HttpCheck(
1462-
request_method=uptime.UptimeCheckConfig.HttpCheck.RequestMethod.GET
1463-
),
14641454
)
14651455
response = client.create_uptime_check_config(request)
14661456

@@ -1738,12 +1728,6 @@ def test_update_uptime_check_config(request_type, transport: str = "grpc"):
17381728
checker_type=uptime.UptimeCheckConfig.CheckerType.STATIC_IP_CHECKERS,
17391729
selected_regions=[uptime.UptimeCheckRegion.USA],
17401730
is_internal=True,
1741-
monitored_resource=monitored_resource_pb2.MonitoredResource(
1742-
type="type_value"
1743-
),
1744-
http_check=uptime.UptimeCheckConfig.HttpCheck(
1745-
request_method=uptime.UptimeCheckConfig.HttpCheck.RequestMethod.GET
1746-
),
17471731
)
17481732
response = client.update_uptime_check_config(request)
17491733

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

0 commit comments

Comments
 (0)