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 #452

Merged
merged 2 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ async def cancel_operation(
metadata=metadata,
)

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ async def cancel_operation(
metadata=metadata,
)

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

async def __aexit__(self, exc_type, exc, tb):
Expand Down
12 changes: 6 additions & 6 deletions google/cloud/datastore_v1/types/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@

class PartitionId(proto.Message):
r"""A partition ID identifies a grouping of entities. The grouping is
always by project. database. and namespace, however the namespace ID may be
empty. Empty database ID refers to the default database.
always by project and namespace, however the namespace ID may be
empty.

A partition ID contains several dimensions: project ID, database ID,
and namespace ID.
A partition ID contains several dimensions: project ID and namespace
ID.

Partition dimensions:

Expand All @@ -54,7 +54,7 @@ class PartitionId(proto.Message):
ID is forbidden in certain documented contexts.

Foreign partition IDs (in which the project ID does not match the
context project ID) are discouraged. Reads and writes of foreign
context project ID ) are discouraged. Reads and writes of foreign
partition IDs may fail if the project is not in an active state.

Attributes:
Expand All @@ -63,7 +63,7 @@ class PartitionId(proto.Message):
belong.
database_id (str):
If not empty, the ID of the database to which
the entities belong. Empty corresponds to the default database.
the entities belong.
namespace_id (str):
If not empty, the ID of the namespace to
which the entities belong.
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/gapic/datastore_admin_v1/test_datastore_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2016,9 +2016,11 @@ async def test_list_indexes_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_indexes(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