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

fix: Add async context manager return types #238

Merged
merged 2 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ async def sample_repair_application():
# Done; return the response.
return response

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

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

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

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

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

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

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

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

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

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

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

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

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

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

async def __aenter__(self):
async def __aenter__(self) -> "VersionsAsyncClient":
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-appengine-admin",
"version": "1.9.2"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1103,9 +1103,11 @@ async def test_list_authorized_certificates_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_authorized_certificates(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 @@ -1084,9 +1084,11 @@ async def test_list_authorized_domains_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_authorized_domains(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
6 changes: 4 additions & 2 deletions tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,9 +1067,11 @@ async def test_list_domain_mappings_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_domain_mappings(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
6 changes: 4 additions & 2 deletions tests/unit/gapic/appengine_admin_v1/test_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,9 +1020,11 @@ async def test_list_ingress_rules_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_ingress_rules(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
6 changes: 4 additions & 2 deletions tests/unit/gapic/appengine_admin_v1/test_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,9 +1022,11 @@ async def test_list_instances_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_instances(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
6 changes: 4 additions & 2 deletions tests/unit/gapic/appengine_admin_v1/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,9 +1015,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
12 changes: 4 additions & 8 deletions tests/unit/gapic/appengine_admin_v1/test_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,9 +1017,11 @@ async def test_list_versions_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_versions(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 @@ -1065,9 +1067,6 @@ def test_get_version(request_type, transport: str = "grpc"):
service_account="service_account_value",
nobuild_files_regex="nobuild_files_regex_value",
version_url="version_url_value",
automatic_scaling=version.AutomaticScaling(
cool_down_period=duration_pb2.Duration(seconds=751)
),
)
response = client.get_version(request)

Expand Down Expand Up @@ -1901,9 +1900,6 @@ def test_get_version_rest(request_type):
service_account="service_account_value",
nobuild_files_regex="nobuild_files_regex_value",
version_url="version_url_value",
automatic_scaling=version.AutomaticScaling(
cool_down_period=duration_pb2.Duration(seconds=751)
),
)

# Wrap the value into a proper Response obj
Expand Down