Skip to content

Commit e82bd0f

Browse files
docs: fix type in docstring for map fields (#210)
* fix: fix type in docstring for map fields PiperOrigin-RevId: 440107808 Source-Link: googleapis/googleapis@258ddb2 Source-Link: googleapis/googleapis-gen@df0d09a Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZGYwZDA5YTJjMzZmZjViYWY5ODY0OGVlZmU1MDI5YzE3MzkwNWQwYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md PiperOrigin-RevId: 440123036 Source-Link: googleapis/googleapis@bc99550 Source-Link: googleapis/googleapis-gen@a0e1d65 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTBlMWQ2NTE1MTI4NzIyYzhjMTYyMTM4N2VhYjM3ODE4NjEyMjc5OCJ9 * 🦉 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>
1 parent 1b6b6d3 commit e82bd0f

13 files changed

Lines changed: 259 additions & 119 deletions

packages/google-cloud-retail/google/cloud/retail_v2/types/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@
6363
PredictRequest,
6464
PredictResponse,
6565
)
66-
from .product import Product
66+
from .product import (
67+
Product,
68+
)
6769
from .product_service import (
6870
AddFulfillmentPlacesMetadata,
6971
AddFulfillmentPlacesRequest,
@@ -87,7 +89,9 @@
8789
SetInventoryResponse,
8890
UpdateProductRequest,
8991
)
90-
from .promotion import Promotion
92+
from .promotion import (
93+
Promotion,
94+
)
9195
from .purge_config import (
9296
PurgeMetadata,
9397
PurgeUserEventsRequest,

packages/google-cloud-retail/google/cloud/retail_v2/types/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ class LocalInventory(proto.Message):
648648
649649
Google Merchant Center property
650650
`price <https://support.google.com/merchants/answer/6324371>`__.
651-
attributes (Sequence[google.cloud.retail_v2.types.LocalInventory.AttributesEntry]):
651+
attributes (Mapping[str, google.cloud.retail_v2.types.CustomAttribute]):
652652
Additional local inventory attributes, for example, store
653653
name, promotion tags, etc.
654654

packages/google-cloud-retail/google/cloud/retail_v2/types/completion_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class CompletionResult(proto.Message):
171171
Attributes:
172172
suggestion (str):
173173
The suggestion for the query.
174-
attributes (Sequence[google.cloud.retail_v2.types.CompleteQueryResponse.CompletionResult.AttributesEntry]):
174+
attributes (Mapping[str, google.cloud.retail_v2.types.CustomAttribute]):
175175
Custom attributes for the suggestion term.
176176
177177
- For "user-data", the attributes are additional custom

packages/google-cloud-retail/google/cloud/retail_v2/types/prediction_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class PredictRequest(proto.Message):
9898
used that returns arbitrary products. Note that
9999
the validate only mode should only be used for
100100
testing the API, or if the model is not ready.
101-
params (Sequence[google.cloud.retail_v2.types.PredictRequest.ParamsEntry]):
101+
params (Mapping[str, google.protobuf.struct_pb2.Value]):
102102
Additional domain specific parameters for the predictions.
103103
104104
Allowed values:
@@ -127,7 +127,7 @@ class PredictRequest(proto.Message):
127127
'low-diversity', 'medium-diversity', 'high-diversity',
128128
'auto-diversity'}. This gives request-level control and
129129
adjusts prediction results based on product category.
130-
labels (Sequence[google.cloud.retail_v2.types.PredictRequest.LabelsEntry]):
130+
labels (Mapping[str, str]):
131131
The labels applied to a resource must meet the following
132132
requirements:
133133
@@ -217,7 +217,7 @@ class PredictionResult(proto.Message):
217217
Attributes:
218218
id (str):
219219
ID of the recommended product
220-
metadata (Sequence[google.cloud.retail_v2.types.PredictResponse.PredictionResult.MetadataEntry]):
220+
metadata (Mapping[str, google.protobuf.struct_pb2.Value]):
221221
Additional product metadata / annotations.
222222
223223
Possible values:

packages/google-cloud-retail/google/cloud/retail_v2/types/product.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class Product(proto.Message):
257257
258258
For product search this field is in use. It defaults to
259259
"en-US" if unset.
260-
attributes (Sequence[google.cloud.retail_v2.types.Product.AttributesEntry]):
260+
attributes (Mapping[str, google.cloud.retail_v2.types.CustomAttribute]):
261261
Highly encouraged. Extra product attributes to be included.
262262
For example, for products, this could include the store
263263
name, vendor, style, color, etc. These are very strong

packages/google-cloud-retail/google/cloud/retail_v2/types/search_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ class SearchResult(proto.Message):
847847
The count of matched
848848
[variant][google.cloud.retail.v2.Product.Type.VARIANT]
849849
[Product][google.cloud.retail.v2.Product]s.
850-
matching_variant_fields (Sequence[google.cloud.retail_v2.types.SearchResponse.SearchResult.MatchingVariantFieldsEntry]):
850+
matching_variant_fields (Mapping[str, google.protobuf.field_mask_pb2.FieldMask]):
851851
If a [variant][google.cloud.retail.v2.Product.Type.VARIANT]
852852
[Product][google.cloud.retail.v2.Product] matches the search
853853
query, this map indicates which
@@ -862,7 +862,7 @@ class SearchResult(proto.Message):
862862
"products.color_info" indicates there is a match between
863863
"sku1" [ColorInfo][google.cloud.retail.v2.ColorInfo] and the
864864
query.
865-
variant_rollup_values (Sequence[google.cloud.retail_v2.types.SearchResponse.SearchResult.VariantRollupValuesEntry]):
865+
variant_rollup_values (Mapping[str, google.protobuf.struct_pb2.Value]):
866866
The rollup matching
867867
[variant][google.cloud.retail.v2.Product.Type.VARIANT]
868868
[Product][google.cloud.retail.v2.Product] attributes. The

packages/google-cloud-retail/google/cloud/retail_v2/types/user_event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class UserEvent(proto.Message):
139139
This field should be set for ``search`` event when
140140
autocomplete function is enabled and the user clicks a
141141
suggestion for search.
142-
attributes (Sequence[google.cloud.retail_v2.types.UserEvent.AttributesEntry]):
142+
attributes (Mapping[str, google.cloud.retail_v2.types.CustomAttribute]):
143143
Extra user event features to include in the recommendation
144144
model.
145145

packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_catalog_service.py

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,24 @@ def test__get_default_mtls_endpoint():
8989

9090

9191
@pytest.mark.parametrize(
92-
"client_class",
92+
"client_class,transport_name",
9393
[
94-
CatalogServiceClient,
95-
CatalogServiceAsyncClient,
94+
(CatalogServiceClient, "grpc"),
95+
(CatalogServiceAsyncClient, "grpc_asyncio"),
9696
],
9797
)
98-
def test_catalog_service_client_from_service_account_info(client_class):
98+
def test_catalog_service_client_from_service_account_info(client_class, transport_name):
9999
creds = ga_credentials.AnonymousCredentials()
100100
with mock.patch.object(
101101
service_account.Credentials, "from_service_account_info"
102102
) as factory:
103103
factory.return_value = creds
104104
info = {"valid": True}
105-
client = client_class.from_service_account_info(info)
105+
client = client_class.from_service_account_info(info, transport=transport_name)
106106
assert client.transport._credentials == creds
107107
assert isinstance(client, client_class)
108108

109-
assert client.transport._host == "retail.googleapis.com:443"
109+
assert client.transport._host == ("retail.googleapis.com:443")
110110

111111

112112
@pytest.mark.parametrize(
@@ -135,27 +135,31 @@ def test_catalog_service_client_service_account_always_use_jwt(
135135

136136

137137
@pytest.mark.parametrize(
138-
"client_class",
138+
"client_class,transport_name",
139139
[
140-
CatalogServiceClient,
141-
CatalogServiceAsyncClient,
140+
(CatalogServiceClient, "grpc"),
141+
(CatalogServiceAsyncClient, "grpc_asyncio"),
142142
],
143143
)
144-
def test_catalog_service_client_from_service_account_file(client_class):
144+
def test_catalog_service_client_from_service_account_file(client_class, transport_name):
145145
creds = ga_credentials.AnonymousCredentials()
146146
with mock.patch.object(
147147
service_account.Credentials, "from_service_account_file"
148148
) as factory:
149149
factory.return_value = creds
150-
client = client_class.from_service_account_file("dummy/file/path.json")
150+
client = client_class.from_service_account_file(
151+
"dummy/file/path.json", transport=transport_name
152+
)
151153
assert client.transport._credentials == creds
152154
assert isinstance(client, client_class)
153155

154-
client = client_class.from_service_account_json("dummy/file/path.json")
156+
client = client_class.from_service_account_json(
157+
"dummy/file/path.json", transport=transport_name
158+
)
155159
assert client.transport._credentials == creds
156160
assert isinstance(client, client_class)
157161

158-
assert client.transport._host == "retail.googleapis.com:443"
162+
assert client.transport._host == ("retail.googleapis.com:443")
159163

160164

161165
def test_catalog_service_client_get_transport_class():
@@ -1011,7 +1015,7 @@ async def test_list_catalogs_async_pager():
10111015
)
10121016
assert async_pager.next_page_token == "abc"
10131017
responses = []
1014-
async for response in async_pager:
1018+
async for response in async_pager: # pragma: no branch
10151019
responses.append(response)
10161020

10171021
assert len(responses) == 6
@@ -1057,7 +1061,9 @@ async def test_list_catalogs_async_pages():
10571061
RuntimeError,
10581062
)
10591063
pages = []
1060-
async for page_ in (await client.list_catalogs(request={})).pages:
1064+
async for page_ in (
1065+
await client.list_catalogs(request={})
1066+
).pages: # pragma: no branch
10611067
pages.append(page_)
10621068
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
10631069
assert page_.raw_page.next_page_token == token
@@ -2072,24 +2078,40 @@ def test_catalog_service_grpc_transport_client_cert_source_for_mtls(transport_cl
20722078
)
20732079

20742080

2075-
def test_catalog_service_host_no_port():
2081+
@pytest.mark.parametrize(
2082+
"transport_name",
2083+
[
2084+
"grpc",
2085+
"grpc_asyncio",
2086+
],
2087+
)
2088+
def test_catalog_service_host_no_port(transport_name):
20762089
client = CatalogServiceClient(
20772090
credentials=ga_credentials.AnonymousCredentials(),
20782091
client_options=client_options.ClientOptions(
20792092
api_endpoint="retail.googleapis.com"
20802093
),
2094+
transport=transport_name,
20812095
)
2082-
assert client.transport._host == "retail.googleapis.com:443"
2096+
assert client.transport._host == ("retail.googleapis.com:443")
20832097

20842098

2085-
def test_catalog_service_host_with_port():
2099+
@pytest.mark.parametrize(
2100+
"transport_name",
2101+
[
2102+
"grpc",
2103+
"grpc_asyncio",
2104+
],
2105+
)
2106+
def test_catalog_service_host_with_port(transport_name):
20862107
client = CatalogServiceClient(
20872108
credentials=ga_credentials.AnonymousCredentials(),
20882109
client_options=client_options.ClientOptions(
20892110
api_endpoint="retail.googleapis.com:8000"
20902111
),
2112+
transport=transport_name,
20912113
)
2092-
assert client.transport._host == "retail.googleapis.com:8000"
2114+
assert client.transport._host == ("retail.googleapis.com:8000")
20932115

20942116

20952117
def test_catalog_service_grpc_transport_channel():

packages/google-cloud-retail/tests/unit/gapic/retail_v2/test_completion_service.py

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,26 @@ def test__get_default_mtls_endpoint():
9494

9595

9696
@pytest.mark.parametrize(
97-
"client_class",
97+
"client_class,transport_name",
9898
[
99-
CompletionServiceClient,
100-
CompletionServiceAsyncClient,
99+
(CompletionServiceClient, "grpc"),
100+
(CompletionServiceAsyncClient, "grpc_asyncio"),
101101
],
102102
)
103-
def test_completion_service_client_from_service_account_info(client_class):
103+
def test_completion_service_client_from_service_account_info(
104+
client_class, transport_name
105+
):
104106
creds = ga_credentials.AnonymousCredentials()
105107
with mock.patch.object(
106108
service_account.Credentials, "from_service_account_info"
107109
) as factory:
108110
factory.return_value = creds
109111
info = {"valid": True}
110-
client = client_class.from_service_account_info(info)
112+
client = client_class.from_service_account_info(info, transport=transport_name)
111113
assert client.transport._credentials == creds
112114
assert isinstance(client, client_class)
113115

114-
assert client.transport._host == "retail.googleapis.com:443"
116+
assert client.transport._host == ("retail.googleapis.com:443")
115117

116118

117119
@pytest.mark.parametrize(
@@ -140,27 +142,33 @@ def test_completion_service_client_service_account_always_use_jwt(
140142

141143

142144
@pytest.mark.parametrize(
143-
"client_class",
145+
"client_class,transport_name",
144146
[
145-
CompletionServiceClient,
146-
CompletionServiceAsyncClient,
147+
(CompletionServiceClient, "grpc"),
148+
(CompletionServiceAsyncClient, "grpc_asyncio"),
147149
],
148150
)
149-
def test_completion_service_client_from_service_account_file(client_class):
151+
def test_completion_service_client_from_service_account_file(
152+
client_class, transport_name
153+
):
150154
creds = ga_credentials.AnonymousCredentials()
151155
with mock.patch.object(
152156
service_account.Credentials, "from_service_account_file"
153157
) as factory:
154158
factory.return_value = creds
155-
client = client_class.from_service_account_file("dummy/file/path.json")
159+
client = client_class.from_service_account_file(
160+
"dummy/file/path.json", transport=transport_name
161+
)
156162
assert client.transport._credentials == creds
157163
assert isinstance(client, client_class)
158164

159-
client = client_class.from_service_account_json("dummy/file/path.json")
165+
client = client_class.from_service_account_json(
166+
"dummy/file/path.json", transport=transport_name
167+
)
160168
assert client.transport._credentials == creds
161169
assert isinstance(client, client_class)
162170

163-
assert client.transport._host == "retail.googleapis.com:443"
171+
assert client.transport._host == ("retail.googleapis.com:443")
164172

165173

166174
def test_completion_service_client_get_transport_class():
@@ -1250,24 +1258,40 @@ def test_completion_service_grpc_transport_client_cert_source_for_mtls(transport
12501258
)
12511259

12521260

1253-
def test_completion_service_host_no_port():
1261+
@pytest.mark.parametrize(
1262+
"transport_name",
1263+
[
1264+
"grpc",
1265+
"grpc_asyncio",
1266+
],
1267+
)
1268+
def test_completion_service_host_no_port(transport_name):
12541269
client = CompletionServiceClient(
12551270
credentials=ga_credentials.AnonymousCredentials(),
12561271
client_options=client_options.ClientOptions(
12571272
api_endpoint="retail.googleapis.com"
12581273
),
1274+
transport=transport_name,
12591275
)
1260-
assert client.transport._host == "retail.googleapis.com:443"
1276+
assert client.transport._host == ("retail.googleapis.com:443")
12611277

12621278

1263-
def test_completion_service_host_with_port():
1279+
@pytest.mark.parametrize(
1280+
"transport_name",
1281+
[
1282+
"grpc",
1283+
"grpc_asyncio",
1284+
],
1285+
)
1286+
def test_completion_service_host_with_port(transport_name):
12641287
client = CompletionServiceClient(
12651288
credentials=ga_credentials.AnonymousCredentials(),
12661289
client_options=client_options.ClientOptions(
12671290
api_endpoint="retail.googleapis.com:8000"
12681291
),
1292+
transport=transport_name,
12691293
)
1270-
assert client.transport._host == "retail.googleapis.com:8000"
1294+
assert client.transport._host == ("retail.googleapis.com:8000")
12711295

12721296

12731297
def test_completion_service_grpc_transport_channel():

0 commit comments

Comments
 (0)