From 35a0ecfed07ef8cb816b00d707743f36c6c9adb5 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 4 Jul 2023 13:14:21 -0400 Subject: [PATCH] fix: Add async context manager return types (#255) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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: https://github.com/googleapis/googleapis/commit/601b5326107eeb74800b426d1f9933faa233258a 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 * revert * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * revert --------- Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .../executions_v1/services/executions/async_client.py | 2 +- .../executions_v1beta/services/executions/async_client.py | 2 +- .../cloud/workflows_v1/services/workflows/async_client.py | 2 +- .../workflows_v1beta/services/workflows/async_client.py | 2 +- .../tests/unit/gapic/executions_v1/test_executions.py | 6 ++++-- .../tests/unit/gapic/executions_v1beta/test_executions.py | 6 ++++-- .../tests/unit/gapic/workflows_v1/test_workflows.py | 6 ++++-- .../tests/unit/gapic/workflows_v1beta/test_workflows.py | 6 ++++-- 8 files changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/async_client.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/async_client.py index e50327cf5fe9..2d567a21bd23 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/async_client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/services/executions/async_client.py @@ -659,7 +659,7 @@ async def sample_cancel_execution(): # Done; return the response. return response - async def __aenter__(self): + async def __aenter__(self) -> "ExecutionsAsyncClient": return self async def __aexit__(self, exc_type, exc, tb): diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/async_client.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/async_client.py index cd4c53aeec9c..a16ed46df490 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/async_client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/services/executions/async_client.py @@ -662,7 +662,7 @@ async def sample_cancel_execution(): # Done; return the response. return response - async def __aenter__(self): + async def __aenter__(self) -> "ExecutionsAsyncClient": return self async def __aexit__(self, exc_type, exc, tb): diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/async_client.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/async_client.py index f58ce361581a..916b9574b0f5 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/async_client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/services/workflows/async_client.py @@ -860,7 +860,7 @@ async def sample_update_workflow(): # Done; return the response. return response - async def __aenter__(self): + async def __aenter__(self) -> "WorkflowsAsyncClient": return self async def __aexit__(self, exc_type, exc, tb): diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/async_client.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/async_client.py index a1cd94de2023..9ebf79b0c045 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/async_client.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/services/workflows/async_client.py @@ -860,7 +860,7 @@ async def sample_update_workflow(): # Done; return the response. return response - async def __aenter__(self): + async def __aenter__(self) -> "WorkflowsAsyncClient": return self async def __aexit__(self, exc_type, exc, tb): diff --git a/packages/google-cloud-workflows/tests/unit/gapic/executions_v1/test_executions.py b/packages/google-cloud-workflows/tests/unit/gapic/executions_v1/test_executions.py index 349515084023..f57698a60cae 100644 --- a/packages/google-cloud-workflows/tests/unit/gapic/executions_v1/test_executions.py +++ b/packages/google-cloud-workflows/tests/unit/gapic/executions_v1/test_executions.py @@ -1070,9 +1070,11 @@ async def test_list_executions_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_executions(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 diff --git a/packages/google-cloud-workflows/tests/unit/gapic/executions_v1beta/test_executions.py b/packages/google-cloud-workflows/tests/unit/gapic/executions_v1beta/test_executions.py index d974e600f52a..0ad302d8b7b6 100644 --- a/packages/google-cloud-workflows/tests/unit/gapic/executions_v1beta/test_executions.py +++ b/packages/google-cloud-workflows/tests/unit/gapic/executions_v1beta/test_executions.py @@ -1070,9 +1070,11 @@ async def test_list_executions_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_executions(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 diff --git a/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py index 77f5ec2407d2..fedd43ee8541 100644 --- a/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py +++ b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py @@ -1104,9 +1104,11 @@ async def test_list_workflows_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_workflows(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 diff --git a/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py index 184ed821c5b3..b0c1473ac03f 100644 --- a/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py +++ b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py @@ -1104,9 +1104,11 @@ async def test_list_workflows_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_workflows(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