Skip to content

Commit

Permalink
fix: Add async context manager return types (#246)
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 fc5ddb7 commit 9946f22
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ async def get_operation(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,16 +464,6 @@ class _AcknowledgeViolation(AssuredWorkloadsServiceRestStub):
def __hash__(self):
return hash("AcknowledgeViolation")

__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}

@classmethod
def _get_unset_required_fields(cls, message_dict):
return {
k: v
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
if k not in message_dict
}

def __call__(
self,
request: assuredworkloads.AcknowledgeViolationRequest,
Expand Down Expand Up @@ -660,16 +650,6 @@ class _GetViolation(AssuredWorkloadsServiceRestStub):
def __hash__(self):
return hash("GetViolation")

__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}

@classmethod
def _get_unset_required_fields(cls, message_dict):
return {
k: v
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
if k not in message_dict
}

def __call__(
self,
request: assuredworkloads.GetViolationRequest,
Expand Down Expand Up @@ -774,16 +754,6 @@ class _ListViolations(AssuredWorkloadsServiceRestStub):
def __hash__(self):
return hash("ListViolations")

__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}

@classmethod
def _get_unset_required_fields(cls, message_dict):
return {
k: v
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
if k not in message_dict
}

def __call__(
self,
request: assuredworkloads.ListViolationsRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ async def get_operation(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,6 @@ class _AnalyzeWorkloadMove(AssuredWorkloadsServiceRestStub):
def __hash__(self):
return hash("AnalyzeWorkloadMove")

__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}

@classmethod
def _get_unset_required_fields(cls, message_dict):
return {
k: v
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
if k not in message_dict
}

def __call__(
self,
request: assuredworkloads.AnalyzeWorkloadMoveRequest,
Expand Down Expand Up @@ -575,16 +565,6 @@ class _GetWorkload(AssuredWorkloadsServiceRestStub):
def __hash__(self):
return hash("GetWorkload")

__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}

@classmethod
def _get_unset_required_fields(cls, message_dict):
return {
k: v
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
if k not in message_dict
}

def __call__(
self,
request: assuredworkloads.GetWorkloadRequest,
Expand All @@ -601,16 +581,6 @@ class _ListWorkloads(AssuredWorkloadsServiceRestStub):
def __hash__(self):
return hash("ListWorkloads")

__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}

@classmethod
def _get_unset_required_fields(cls, message_dict):
return {
k: v
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
if k not in message_dict
}

def __call__(
self,
request: assuredworkloads.ListWorkloadsRequest,
Expand Down Expand Up @@ -729,16 +699,6 @@ class _UpdateWorkload(AssuredWorkloadsServiceRestStub):
def __hash__(self):
return hash("UpdateWorkload")

__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}

@classmethod
def _get_unset_required_fields(cls, message_dict):
return {
k: v
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
if k not in message_dict
}

def __call__(
self,
request: assuredworkloads.UpdateWorkloadRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-assured-workloads",
"version": "1.10.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-assured-workloads",
"version": "1.10.1"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2360,9 +2360,11 @@ async def test_list_workloads_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_workloads(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 @@ -2716,9 +2718,11 @@ async def test_list_violations_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_violations(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
Original file line number Diff line number Diff line change
Expand Up @@ -1031,11 +1031,6 @@ def test_update_workload(request_type, transport: str = "grpc"):
compliant_but_disallowed_services=[
"compliant_but_disallowed_services_value"
],
il4_settings=assuredworkloads.Workload.IL4Settings(
kms_settings=assuredworkloads.Workload.KMSSettings(
next_rotation_time=timestamp_pb2.Timestamp(seconds=751)
)
),
)
response = client.update_workload(request)

Expand Down Expand Up @@ -1638,11 +1633,6 @@ def test_get_workload(request_type, transport: str = "grpc"):
compliant_but_disallowed_services=[
"compliant_but_disallowed_services_value"
],
il4_settings=assuredworkloads.Workload.IL4Settings(
kms_settings=assuredworkloads.Workload.KMSSettings(
next_rotation_time=timestamp_pb2.Timestamp(seconds=751)
)
),
)
response = client.get_workload(request)

Expand Down Expand Up @@ -2364,9 +2354,11 @@ async def test_list_workloads_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_workloads(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 9946f22

Please sign in to comment.