Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
fix: Add async context manager return types (#522)
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] committed Jul 4, 2023
1 parent dd6e794 commit d473ad3
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 23 deletions.
2 changes: 1 addition & 1 deletion google/cloud/speech_v1/services/adaptation/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ async def get_operation(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/speech_v1/services/speech/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ async def get_operation(
# Done; return the response.
return response

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

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

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

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

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/speech_v2/services/speech/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3511,7 +3511,7 @@ async def list_locations(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/speech_v2/services/speech/transports/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3548,7 +3548,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"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-speech",
"version": "2.20.0"
"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-speech",
"version": "2.20.0"
"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-speech",
"version": "2.20.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
12 changes: 8 additions & 4 deletions tests/unit/gapic/speech_v1/test_adaptation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1597,9 +1597,11 @@ async def test_list_phrase_set_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_phrase_set(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 @@ -3040,9 +3042,11 @@ async def test_list_custom_classes_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_custom_classes(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: 8 additions & 4 deletions tests/unit/gapic/speech_v1p1beta1/test_adaptation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1597,9 +1597,11 @@ async def test_list_phrase_set_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_phrase_set(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 @@ -3040,9 +3042,11 @@ async def test_list_custom_classes_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_custom_classes(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
18 changes: 12 additions & 6 deletions tests/unit/gapic/speech_v2/test_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -1341,9 +1341,11 @@ async def test_list_recognizers_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_recognizers(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 @@ -4103,9 +4105,11 @@ async def test_list_custom_classes_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_custom_classes(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 @@ -5774,9 +5778,11 @@ async def test_list_phrase_sets_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_phrase_sets(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

0 comments on commit d473ad3

Please sign in to comment.