Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add async context manager return types #11446

Merged
merged 5 commits into from Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.9.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.9.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Expand Up @@ -409,7 +409,7 @@ async def get_operation(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Expand Up @@ -1138,7 +1138,7 @@ async def get_operation(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Expand Up @@ -929,7 +929,7 @@ async def get_operation(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Expand Up @@ -427,7 +427,7 @@ async def get_operation(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Expand Up @@ -668,7 +668,7 @@ async def get_operation(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.9.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Expand Up @@ -409,7 +409,7 @@ async def get_operation(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Expand Up @@ -1141,7 +1141,7 @@ async def get_operation(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Expand Up @@ -417,7 +417,7 @@ async def get_operation(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Expand Up @@ -929,7 +929,7 @@ async def get_operation(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Expand Up @@ -427,7 +427,7 @@ async def get_operation(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Expand Up @@ -668,7 +668,7 @@ async def get_operation(
# Done; return the response.
return response

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
3 changes: 1 addition & 2 deletions packages/google-cloud-discoveryengine/noxfile.py
Expand Up @@ -305,10 +305,9 @@ def docfx(session):

session.install("-e", ".")
session.install(
"sphinx==4.0.1",
"gcp-sphinx-docfx-yaml",
"alabaster",
"recommonmark",
"gcp-sphinx-docfx-yaml",
)

shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
Expand Down
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-discoveryengine",
"version": "0.9.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-discoveryengine",
"version": "0.9.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Expand Up @@ -769,13 +769,7 @@ def test_get_document(request_type, transport: str = "grpc"):
id="id_value",
schema_id="schema_id_value",
parent_document_id="parent_document_id_value",
struct_data=struct_pb2.Struct(
fields={
"key_value": struct_pb2.Value(
null_value=struct_pb2.NullValue.NULL_VALUE
)
}
),
json_data="json_data_value",
)
response = client.get_document(request)

Expand Down Expand Up @@ -1403,9 +1397,11 @@ async def test_list_documents_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_documents(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 @@ -1436,13 +1432,7 @@ def test_create_document(request_type, transport: str = "grpc"):
id="id_value",
schema_id="schema_id_value",
parent_document_id="parent_document_id_value",
struct_data=struct_pb2.Struct(
fields={
"key_value": struct_pb2.Value(
null_value=struct_pb2.NullValue.NULL_VALUE
)
}
),
json_data="json_data_value",
)
response = client.create_document(request)

Expand Down Expand Up @@ -1755,13 +1745,7 @@ def test_update_document(request_type, transport: str = "grpc"):
id="id_value",
schema_id="schema_id_value",
parent_document_id="parent_document_id_value",
struct_data=struct_pb2.Struct(
fields={
"key_value": struct_pb2.Value(
null_value=struct_pb2.NullValue.NULL_VALUE
)
}
),
json_data="json_data_value",
)
response = client.update_document(request)

Expand Down Expand Up @@ -2432,13 +2416,7 @@ def test_get_document_rest(request_type):
id="id_value",
schema_id="schema_id_value",
parent_document_id="parent_document_id_value",
struct_data=struct_pb2.Struct(
fields={
"key_value": struct_pb2.Value(
null_value=struct_pb2.NullValue.NULL_VALUE
)
}
),
json_data="json_data_value",
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -3079,13 +3057,7 @@ def test_create_document_rest(request_type):
id="id_value",
schema_id="schema_id_value",
parent_document_id="parent_document_id_value",
struct_data=struct_pb2.Struct(
fields={
"key_value": struct_pb2.Value(
null_value=struct_pb2.NullValue.NULL_VALUE
)
}
),
json_data="json_data_value",
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -3441,13 +3413,7 @@ def test_update_document_rest(request_type):
id="id_value",
schema_id="schema_id_value",
parent_document_id="parent_document_id_value",
struct_data=struct_pb2.Struct(
fields={
"key_value": struct_pb2.Value(
null_value=struct_pb2.NullValue.NULL_VALUE
)
}
),
json_data="json_data_value",
)

# Wrap the value into a proper Response obj
Expand Down
Expand Up @@ -738,13 +738,7 @@ def test_get_schema(request_type, transport: str = "grpc"):
# Designate an appropriate return value for the call.
call.return_value = schema.Schema(
name="name_value",
struct_schema=struct_pb2.Struct(
fields={
"key_value": struct_pb2.Value(
null_value=struct_pb2.NullValue.NULL_VALUE
)
}
),
json_schema="json_schema_value",
)
response = client.get_schema(request)

Expand Down Expand Up @@ -1363,9 +1357,11 @@ async def test_list_schemas_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_schemas(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 @@ -2059,13 +2055,7 @@ def test_get_schema_rest(request_type):
# Designate an appropriate value for the returned response.
return_value = schema.Schema(
name="name_value",
struct_schema=struct_pb2.Struct(
fields={
"key_value": struct_pb2.Value(
null_value=struct_pb2.NullValue.NULL_VALUE
)
}
),
json_schema="json_schema_value",
)

# Wrap the value into a proper Response obj
Expand Down
Expand Up @@ -1050,6 +1050,8 @@ async def test_search_async_pages():
RuntimeError,
)
pages = []
# 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 (await client.search(request={})).pages: # pragma: no branch
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
Expand Down