Skip to content

Commit

Permalink
fix: Add async context manager return types (#215)
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 c193628 commit 7bd568b
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ async def sample_delete_attestor():
metadata=metadata,
)

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

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

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

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

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

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

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

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

async def __aenter__(self):
async def __aenter__(self) -> "SystemPolicyV1Beta1AsyncClient":
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-binary-authorization",
"version": "1.6.1"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-binary-authorization",
"version": "1.6.1"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1265,9 +1265,6 @@ def test_create_attestor(request_type, transport: str = "grpc"):
call.return_value = resources.Attestor(
name="name_value",
description="description_value",
user_owned_grafeas_note=resources.UserOwnedGrafeasNote(
note_reference="note_reference_value"
),
)
response = client.create_attestor(request)

Expand Down Expand Up @@ -1520,9 +1517,6 @@ def test_get_attestor(request_type, transport: str = "grpc"):
call.return_value = resources.Attestor(
name="name_value",
description="description_value",
user_owned_grafeas_note=resources.UserOwnedGrafeasNote(
note_reference="note_reference_value"
),
)
response = client.get_attestor(request)

Expand Down Expand Up @@ -1755,9 +1749,6 @@ def test_update_attestor(request_type, transport: str = "grpc"):
call.return_value = resources.Attestor(
name="name_value",
description="description_value",
user_owned_grafeas_note=resources.UserOwnedGrafeasNote(
note_reference="note_reference_value"
),
)
response = client.update_attestor(request)

Expand Down Expand Up @@ -2379,9 +2370,11 @@ async def test_list_attestors_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_attestors(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 @@ -3218,9 +3211,6 @@ def test_create_attestor_rest(request_type):
return_value = resources.Attestor(
name="name_value",
description="description_value",
user_owned_grafeas_note=resources.UserOwnedGrafeasNote(
note_reference="note_reference_value"
),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -3534,9 +3524,6 @@ def test_get_attestor_rest(request_type):
return_value = resources.Attestor(
name="name_value",
description="description_value",
user_owned_grafeas_note=resources.UserOwnedGrafeasNote(
note_reference="note_reference_value"
),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -3819,9 +3806,6 @@ def test_update_attestor_rest(request_type):
return_value = resources.Attestor(
name="name_value",
description="description_value",
user_owned_grafeas_note=resources.UserOwnedGrafeasNote(
note_reference="note_reference_value"
),
)

# Wrap the value into a proper Response obj
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1277,9 +1277,6 @@ def test_create_attestor(request_type, transport: str = "grpc"):
call.return_value = resources.Attestor(
name="name_value",
description="description_value",
user_owned_drydock_note=resources.UserOwnedDrydockNote(
note_reference="note_reference_value"
),
)
response = client.create_attestor(request)

Expand Down Expand Up @@ -1532,9 +1529,6 @@ def test_get_attestor(request_type, transport: str = "grpc"):
call.return_value = resources.Attestor(
name="name_value",
description="description_value",
user_owned_drydock_note=resources.UserOwnedDrydockNote(
note_reference="note_reference_value"
),
)
response = client.get_attestor(request)

Expand Down Expand Up @@ -1767,9 +1761,6 @@ def test_update_attestor(request_type, transport: str = "grpc"):
call.return_value = resources.Attestor(
name="name_value",
description="description_value",
user_owned_drydock_note=resources.UserOwnedDrydockNote(
note_reference="note_reference_value"
),
)
response = client.update_attestor(request)

Expand Down Expand Up @@ -2391,9 +2382,11 @@ async def test_list_attestors_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_attestors(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 @@ -3231,9 +3224,6 @@ def test_create_attestor_rest(request_type):
return_value = resources.Attestor(
name="name_value",
description="description_value",
user_owned_drydock_note=resources.UserOwnedDrydockNote(
note_reference="note_reference_value"
),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -3549,9 +3539,6 @@ def test_get_attestor_rest(request_type):
return_value = resources.Attestor(
name="name_value",
description="description_value",
user_owned_drydock_note=resources.UserOwnedDrydockNote(
note_reference="note_reference_value"
),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -3834,9 +3821,6 @@ def test_update_attestor_rest(request_type):
return_value = resources.Attestor(
name="name_value",
description="description_value",
user_owned_drydock_note=resources.UserOwnedDrydockNote(
note_reference="note_reference_value"
),
)

# Wrap the value into a proper Response obj
Expand Down

0 comments on commit 7bd568b

Please sign in to comment.