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

Commit

Permalink
fix: Add async context manager return types (#248)
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: 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

---------

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 0d46fe2 commit 34fc787
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion grafeas/grafeas_v1/services/grafeas/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ async def sample_list_note_occurrences():
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
32 changes: 12 additions & 20 deletions tests/unit/gapic/grafeas_v1/test_grafeas.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def test_get_occurrence(request_type, transport: str = "grpc"):
note_name="note_name_value",
kind=common.NoteKind.VULNERABILITY,
remediation="remediation_value",
vulnerability=vulnerability.VulnerabilityOccurrence(type_="type__value"),
)
response = client.get_occurrence(request)

Expand Down Expand Up @@ -748,9 +747,11 @@ async def test_list_occurrences_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_occurrences(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 @@ -1018,7 +1019,6 @@ def test_create_occurrence(request_type, transport: str = "grpc"):
note_name="note_name_value",
kind=common.NoteKind.VULNERABILITY,
remediation="remediation_value",
vulnerability=vulnerability.VulnerabilityOccurrence(type_="type__value"),
)
response = client.create_occurrence(request)

Expand Down Expand Up @@ -1537,7 +1537,6 @@ def test_update_occurrence(request_type, transport: str = "grpc"):
note_name="note_name_value",
kind=common.NoteKind.VULNERABILITY,
remediation="remediation_value",
vulnerability=vulnerability.VulnerabilityOccurrence(type_="type__value"),
)
response = client.update_occurrence(request)

Expand Down Expand Up @@ -1816,7 +1815,6 @@ def test_get_occurrence_note(request_type, transport: str = "grpc"):
long_description="long_description_value",
kind=common.NoteKind.VULNERABILITY,
related_note_names=["related_note_names_value"],
vulnerability=vulnerability.VulnerabilityNote(cvss_score=0.1082),
)
response = client.get_occurrence_note(request)

Expand Down Expand Up @@ -2073,7 +2071,6 @@ def test_get_note(request_type, transport: str = "grpc"):
long_description="long_description_value",
kind=common.NoteKind.VULNERABILITY,
related_note_names=["related_note_names_value"],
vulnerability=vulnerability.VulnerabilityNote(cvss_score=0.1082),
)
response = client.get_note(request)

Expand Down Expand Up @@ -2714,9 +2711,11 @@ async def test_list_notes_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_notes(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 @@ -2968,7 +2967,6 @@ def test_create_note(request_type, transport: str = "grpc"):
long_description="long_description_value",
kind=common.NoteKind.VULNERABILITY,
related_note_names=["related_note_names_value"],
vulnerability=vulnerability.VulnerabilityNote(cvss_score=0.1082),
)
response = client.create_note(request)

Expand Down Expand Up @@ -3483,7 +3481,6 @@ def test_update_note(request_type, transport: str = "grpc"):
long_description="long_description_value",
kind=common.NoteKind.VULNERABILITY,
related_note_names=["related_note_names_value"],
vulnerability=vulnerability.VulnerabilityNote(cvss_score=0.1082),
)
response = client.update_note(request)

Expand Down Expand Up @@ -4166,9 +4163,11 @@ async def test_list_note_occurrences_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_note_occurrences(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 @@ -4200,7 +4199,6 @@ def test_get_occurrence_rest(request_type):
note_name="note_name_value",
kind=common.NoteKind.VULNERABILITY,
remediation="remediation_value",
vulnerability=vulnerability.VulnerabilityOccurrence(type_="type__value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -5358,7 +5356,6 @@ def test_create_occurrence_rest(request_type):
note_name="note_name_value",
kind=common.NoteKind.VULNERABILITY,
remediation="remediation_value",
vulnerability=vulnerability.VulnerabilityOccurrence(type_="type__value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -6526,7 +6523,6 @@ def test_update_occurrence_rest(request_type):
note_name="note_name_value",
kind=common.NoteKind.VULNERABILITY,
remediation="remediation_value",
vulnerability=vulnerability.VulnerabilityOccurrence(type_="type__value"),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -7118,7 +7114,6 @@ def test_get_occurrence_note_rest(request_type):
long_description="long_description_value",
kind=common.NoteKind.VULNERABILITY,
related_note_names=["related_note_names_value"],
vulnerability=vulnerability.VulnerabilityNote(cvss_score=0.1082),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -7390,7 +7385,6 @@ def test_get_note_rest(request_type):
long_description="long_description_value",
kind=common.NoteKind.VULNERABILITY,
related_note_names=["related_note_names_value"],
vulnerability=vulnerability.VulnerabilityNote(cvss_score=0.1082),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -8426,7 +8420,6 @@ def test_create_note_rest(request_type):
long_description="long_description_value",
kind=common.NoteKind.VULNERABILITY,
related_note_names=["related_note_names_value"],
vulnerability=vulnerability.VulnerabilityNote(cvss_score=0.1082),
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -9375,7 +9368,6 @@ def test_update_note_rest(request_type):
long_description="long_description_value",
kind=common.NoteKind.VULNERABILITY,
related_note_names=["related_note_names_value"],
vulnerability=vulnerability.VulnerabilityNote(cvss_score=0.1082),
)

# Wrap the value into a proper Response obj
Expand Down

0 comments on commit 34fc787

Please sign in to comment.