diff --git a/google/cloud/batch_v1/services/batch_service/async_client.py b/google/cloud/batch_v1/services/batch_service/async_client.py index 0258035..9bbf7a3 100644 --- a/google/cloud/batch_v1/services/batch_service/async_client.py +++ b/google/cloud/batch_v1/services/batch_service/async_client.py @@ -1252,7 +1252,7 @@ async def list_locations( # Done; return the response. return response - async def __aenter__(self): + async def __aenter__(self) -> "BatchServiceAsyncClient": return self async def __aexit__(self, exc_type, exc, tb): diff --git a/google/cloud/batch_v1/services/batch_service/transports/rest.py b/google/cloud/batch_v1/services/batch_service/transports/rest.py index 7679d6c..3fba50f 100644 --- a/google/cloud/batch_v1/services/batch_service/transports/rest.py +++ b/google/cloud/batch_v1/services/batch_service/transports/rest.py @@ -1253,7 +1253,7 @@ def __call__( request_kwargs = json_format.MessageToDict(request) transcoded_request = path_template.transcode(http_options, **request_kwargs) - body = json.loads(json.dumps(transcoded_request["body"])) + body = json.dumps(transcoded_request["body"]) uri = transcoded_request["uri"] method = transcoded_request["method"] diff --git a/google/cloud/batch_v1alpha/services/batch_service/async_client.py b/google/cloud/batch_v1alpha/services/batch_service/async_client.py index fc31ab2..b4ef0d0 100644 --- a/google/cloud/batch_v1alpha/services/batch_service/async_client.py +++ b/google/cloud/batch_v1alpha/services/batch_service/async_client.py @@ -1252,7 +1252,7 @@ async def list_locations( # Done; return the response. return response - async def __aenter__(self): + async def __aenter__(self) -> "BatchServiceAsyncClient": return self async def __aexit__(self, exc_type, exc, tb): diff --git a/google/cloud/batch_v1alpha/services/batch_service/transports/rest.py b/google/cloud/batch_v1alpha/services/batch_service/transports/rest.py index 6749823..eb84d63 100644 --- a/google/cloud/batch_v1alpha/services/batch_service/transports/rest.py +++ b/google/cloud/batch_v1alpha/services/batch_service/transports/rest.py @@ -1253,7 +1253,7 @@ def __call__( request_kwargs = json_format.MessageToDict(request) transcoded_request = path_template.transcode(http_options, **request_kwargs) - body = json.loads(json.dumps(transcoded_request["body"])) + body = json.dumps(transcoded_request["body"]) uri = transcoded_request["uri"] method = transcoded_request["method"] diff --git a/tests/unit/gapic/batch_v1/test_batch_service.py b/tests/unit/gapic/batch_v1/test_batch_service.py index e4f31a4..caf1ef9 100644 --- a/tests/unit/gapic/batch_v1/test_batch_service.py +++ b/tests/unit/gapic/batch_v1/test_batch_service.py @@ -1840,9 +1840,11 @@ async def test_list_jobs_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_jobs(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 @@ -2492,9 +2494,11 @@ async def test_list_tasks_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_tasks(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/tests/unit/gapic/batch_v1alpha/test_batch_service.py b/tests/unit/gapic/batch_v1alpha/test_batch_service.py index d1aa93f..e356560 100644 --- a/tests/unit/gapic/batch_v1alpha/test_batch_service.py +++ b/tests/unit/gapic/batch_v1alpha/test_batch_service.py @@ -1852,9 +1852,11 @@ async def test_list_jobs_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_jobs(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 @@ -2504,9 +2506,11 @@ async def test_list_tasks_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_tasks(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