Skip to content

Commit 32265bb

Browse files
dpebottseaver
authored andcommitted
Fix client_info bug, update docstrings. (#6415)
1 parent 8ad195a commit 32265bb

File tree

4 files changed

+64
-48
lines changed

4 files changed

+64
-48
lines changed

language/google/cloud/language_v1/gapic/enums.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@
2121
class EncodingType(enum.IntEnum):
2222
"""
2323
Represents the text encoding that the caller uses to process the output.
24-
Providing an ``EncodingType`` is recommended because the API provides the
25-
beginning offsets for various outputs, such as tokens and mentions, and
26-
languages that natively use different text encodings may access offsets
27-
differently.
24+
Providing an ``EncodingType`` is recommended because the API provides
25+
the beginning offsets for various outputs, such as tokens and mentions,
26+
and languages that natively use different text encodings may access
27+
offsets differently.
2828
2929
Attributes:
30-
NONE (int): If ``EncodingType`` is not specified, encoding-dependent information (such as
31-
``begin_offset``) will be set at ``-1``.
32-
UTF8 (int): Encoding-dependent information (such as ``begin_offset``) is calculated based
33-
on the UTF-8 encoding of the input. C++ and Go are examples of languages
34-
that use this encoding natively.
35-
UTF16 (int): Encoding-dependent information (such as ``begin_offset``) is calculated based
36-
on the UTF-16 encoding of the input. Java and Javascript are examples of
30+
NONE (int): If ``EncodingType`` is not specified, encoding-dependent information
31+
(such as ``begin_offset``) will be set at ``-1``.
32+
UTF8 (int): Encoding-dependent information (such as ``begin_offset``) is calculated
33+
based on the UTF-8 encoding of the input. C++ and Go are examples of
3734
languages that use this encoding natively.
38-
UTF32 (int): Encoding-dependent information (such as ``begin_offset``) is calculated based
39-
on the UTF-32 encoding of the input. Python is an example of a language
40-
that uses this encoding natively.
35+
UTF16 (int): Encoding-dependent information (such as ``begin_offset``) is calculated
36+
based on the UTF-16 encoding of the input. Java and Javascript are
37+
examples of languages that use this encoding natively.
38+
UTF32 (int): Encoding-dependent information (such as ``begin_offset``) is calculated
39+
based on the UTF-32 encoding of the input. Python is an example of a
40+
language that uses this encoding natively.
4141
"""
4242
NONE = 0
4343
UTF8 = 1

language/google/cloud/language_v1/gapic/language_service_client.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,10 @@ def __init__(self,
138138
)
139139

140140
if client_info is None:
141-
client_info = (
142-
google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO)
143-
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
141+
client_info = google.api_core.gapic_v1.client_info.ClientInfo(
142+
gapic_version=_GAPIC_LIBRARY_VERSION, )
143+
else:
144+
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
144145
self._client_info = client_info
145146

146147
# Parse out the default settings for retry and timeout for each RPC
@@ -171,13 +172,14 @@ def analyze_sentiment(self,
171172
>>>
172173
>>> client = language_v1.LanguageServiceClient()
173174
>>>
174-
>>> # TODO: Initialize ``document``:
175+
>>> # TODO: Initialize `document`:
175176
>>> document = {}
176177
>>>
177178
>>> response = client.analyze_sentiment(document)
178179
179180
Args:
180181
document (Union[dict, ~google.cloud.language_v1.types.Document]): Input document.
182+
181183
If a dict is provided, it must be of the same form as the protobuf
182184
message :class:`~google.cloud.language_v1.types.Document`
183185
encoding_type (~google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate sentence offsets.
@@ -235,13 +237,14 @@ def analyze_entities(self,
235237
>>>
236238
>>> client = language_v1.LanguageServiceClient()
237239
>>>
238-
>>> # TODO: Initialize ``document``:
240+
>>> # TODO: Initialize `document`:
239241
>>> document = {}
240242
>>>
241243
>>> response = client.analyze_entities(document)
242244
243245
Args:
244246
document (Union[dict, ~google.cloud.language_v1.types.Document]): Input document.
247+
245248
If a dict is provided, it must be of the same form as the protobuf
246249
message :class:`~google.cloud.language_v1.types.Document`
247250
encoding_type (~google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets.
@@ -299,13 +302,14 @@ def analyze_entity_sentiment(
299302
>>>
300303
>>> client = language_v1.LanguageServiceClient()
301304
>>>
302-
>>> # TODO: Initialize ``document``:
305+
>>> # TODO: Initialize `document`:
303306
>>> document = {}
304307
>>>
305308
>>> response = client.analyze_entity_sentiment(document)
306309
307310
Args:
308311
document (Union[dict, ~google.cloud.language_v1.types.Document]): Input document.
312+
309313
If a dict is provided, it must be of the same form as the protobuf
310314
message :class:`~google.cloud.language_v1.types.Document`
311315
encoding_type (~google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets.
@@ -363,13 +367,14 @@ def analyze_syntax(self,
363367
>>>
364368
>>> client = language_v1.LanguageServiceClient()
365369
>>>
366-
>>> # TODO: Initialize ``document``:
370+
>>> # TODO: Initialize `document`:
367371
>>> document = {}
368372
>>>
369373
>>> response = client.analyze_syntax(document)
370374
371375
Args:
372376
document (Union[dict, ~google.cloud.language_v1.types.Document]): Input document.
377+
373378
If a dict is provided, it must be of the same form as the protobuf
374379
message :class:`~google.cloud.language_v1.types.Document`
375380
encoding_type (~google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets.
@@ -423,13 +428,14 @@ def classify_text(self,
423428
>>>
424429
>>> client = language_v1.LanguageServiceClient()
425430
>>>
426-
>>> # TODO: Initialize ``document``:
431+
>>> # TODO: Initialize `document`:
427432
>>> document = {}
428433
>>>
429434
>>> response = client.classify_text(document)
430435
431436
Args:
432437
document (Union[dict, ~google.cloud.language_v1.types.Document]): Input document.
438+
433439
If a dict is provided, it must be of the same form as the protobuf
434440
message :class:`~google.cloud.language_v1.types.Document`
435441
retry (Optional[google.api_core.retry.Retry]): A retry object used
@@ -482,19 +488,21 @@ def annotate_text(self,
482488
>>>
483489
>>> client = language_v1.LanguageServiceClient()
484490
>>>
485-
>>> # TODO: Initialize ``document``:
491+
>>> # TODO: Initialize `document`:
486492
>>> document = {}
487493
>>>
488-
>>> # TODO: Initialize ``features``:
494+
>>> # TODO: Initialize `features`:
489495
>>> features = {}
490496
>>>
491497
>>> response = client.annotate_text(document, features)
492498
493499
Args:
494500
document (Union[dict, ~google.cloud.language_v1.types.Document]): Input document.
501+
495502
If a dict is provided, it must be of the same form as the protobuf
496503
message :class:`~google.cloud.language_v1.types.Document`
497504
features (Union[dict, ~google.cloud.language_v1.types.Features]): The enabled features.
505+
498506
If a dict is provided, it must be of the same form as the protobuf
499507
message :class:`~google.cloud.language_v1.types.Features`
500508
encoding_type (~google.cloud.language_v1.types.EncodingType): The encoding type used by the API to calculate offsets.

language/google/cloud/language_v1beta2/gapic/enums.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@
2121
class EncodingType(enum.IntEnum):
2222
"""
2323
Represents the text encoding that the caller uses to process the output.
24-
Providing an ``EncodingType`` is recommended because the API provides the
25-
beginning offsets for various outputs, such as tokens and mentions, and
26-
languages that natively use different text encodings may access offsets
27-
differently.
24+
Providing an ``EncodingType`` is recommended because the API provides
25+
the beginning offsets for various outputs, such as tokens and mentions,
26+
and languages that natively use different text encodings may access
27+
offsets differently.
2828
2929
Attributes:
30-
NONE (int): If ``EncodingType`` is not specified, encoding-dependent information (such as
31-
``begin_offset``) will be set at ``-1``.
32-
UTF8 (int): Encoding-dependent information (such as ``begin_offset``) is calculated based
33-
on the UTF-8 encoding of the input. C++ and Go are examples of languages
34-
that use this encoding natively.
35-
UTF16 (int): Encoding-dependent information (such as ``begin_offset``) is calculated based
36-
on the UTF-16 encoding of the input. Java and Javascript are examples of
30+
NONE (int): If ``EncodingType`` is not specified, encoding-dependent information
31+
(such as ``begin_offset``) will be set at ``-1``.
32+
UTF8 (int): Encoding-dependent information (such as ``begin_offset``) is calculated
33+
based on the UTF-8 encoding of the input. C++ and Go are examples of
3734
languages that use this encoding natively.
38-
UTF32 (int): Encoding-dependent information (such as ``begin_offset``) is calculated based
39-
on the UTF-32 encoding of the input. Python is an example of a language
40-
that uses this encoding natively.
35+
UTF16 (int): Encoding-dependent information (such as ``begin_offset``) is calculated
36+
based on the UTF-16 encoding of the input. Java and Javascript are
37+
examples of languages that use this encoding natively.
38+
UTF32 (int): Encoding-dependent information (such as ``begin_offset``) is calculated
39+
based on the UTF-32 encoding of the input. Python is an example of a
40+
language that uses this encoding natively.
4141
"""
4242
NONE = 0
4343
UTF8 = 1

language/google/cloud/language_v1beta2/gapic/language_service_client.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,10 @@ def __init__(self,
138138
)
139139

140140
if client_info is None:
141-
client_info = (
142-
google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO)
143-
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
141+
client_info = google.api_core.gapic_v1.client_info.ClientInfo(
142+
gapic_version=_GAPIC_LIBRARY_VERSION, )
143+
else:
144+
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
144145
self._client_info = client_info
145146

146147
# Parse out the default settings for retry and timeout for each RPC
@@ -171,13 +172,14 @@ def analyze_sentiment(self,
171172
>>>
172173
>>> client = language_v1beta2.LanguageServiceClient()
173174
>>>
174-
>>> # TODO: Initialize ``document``:
175+
>>> # TODO: Initialize `document`:
175176
>>> document = {}
176177
>>>
177178
>>> response = client.analyze_sentiment(document)
178179
179180
Args:
180181
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
182+
181183
If a dict is provided, it must be of the same form as the protobuf
182184
message :class:`~google.cloud.language_v1beta2.types.Document`
183185
encoding_type (~google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate sentence offsets for the
@@ -236,13 +238,14 @@ def analyze_entities(self,
236238
>>>
237239
>>> client = language_v1beta2.LanguageServiceClient()
238240
>>>
239-
>>> # TODO: Initialize ``document``:
241+
>>> # TODO: Initialize `document`:
240242
>>> document = {}
241243
>>>
242244
>>> response = client.analyze_entities(document)
243245
244246
Args:
245247
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
248+
246249
If a dict is provided, it must be of the same form as the protobuf
247250
message :class:`~google.cloud.language_v1beta2.types.Document`
248251
encoding_type (~google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets.
@@ -300,13 +303,14 @@ def analyze_entity_sentiment(
300303
>>>
301304
>>> client = language_v1beta2.LanguageServiceClient()
302305
>>>
303-
>>> # TODO: Initialize ``document``:
306+
>>> # TODO: Initialize `document`:
304307
>>> document = {}
305308
>>>
306309
>>> response = client.analyze_entity_sentiment(document)
307310
308311
Args:
309312
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
313+
310314
If a dict is provided, it must be of the same form as the protobuf
311315
message :class:`~google.cloud.language_v1beta2.types.Document`
312316
encoding_type (~google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets.
@@ -364,13 +368,14 @@ def analyze_syntax(self,
364368
>>>
365369
>>> client = language_v1beta2.LanguageServiceClient()
366370
>>>
367-
>>> # TODO: Initialize ``document``:
371+
>>> # TODO: Initialize `document`:
368372
>>> document = {}
369373
>>>
370374
>>> response = client.analyze_syntax(document)
371375
372376
Args:
373377
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
378+
374379
If a dict is provided, it must be of the same form as the protobuf
375380
message :class:`~google.cloud.language_v1beta2.types.Document`
376381
encoding_type (~google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets.
@@ -424,13 +429,14 @@ def classify_text(self,
424429
>>>
425430
>>> client = language_v1beta2.LanguageServiceClient()
426431
>>>
427-
>>> # TODO: Initialize ``document``:
432+
>>> # TODO: Initialize `document`:
428433
>>> document = {}
429434
>>>
430435
>>> response = client.classify_text(document)
431436
432437
Args:
433438
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
439+
434440
If a dict is provided, it must be of the same form as the protobuf
435441
message :class:`~google.cloud.language_v1beta2.types.Document`
436442
retry (Optional[google.api_core.retry.Retry]): A retry object used
@@ -483,19 +489,21 @@ def annotate_text(self,
483489
>>>
484490
>>> client = language_v1beta2.LanguageServiceClient()
485491
>>>
486-
>>> # TODO: Initialize ``document``:
492+
>>> # TODO: Initialize `document`:
487493
>>> document = {}
488494
>>>
489-
>>> # TODO: Initialize ``features``:
495+
>>> # TODO: Initialize `features`:
490496
>>> features = {}
491497
>>>
492498
>>> response = client.annotate_text(document, features)
493499
494500
Args:
495501
document (Union[dict, ~google.cloud.language_v1beta2.types.Document]): Input document.
502+
496503
If a dict is provided, it must be of the same form as the protobuf
497504
message :class:`~google.cloud.language_v1beta2.types.Document`
498505
features (Union[dict, ~google.cloud.language_v1beta2.types.Features]): The enabled features.
506+
499507
If a dict is provided, it must be of the same form as the protobuf
500508
message :class:`~google.cloud.language_v1beta2.types.Features`
501509
encoding_type (~google.cloud.language_v1beta2.types.EncodingType): The encoding type used by the API to calculate offsets.

0 commit comments

Comments
 (0)