Skip to content

Commit 376b739

Browse files
chore(language): update 'cloud-client' samples (#13174)
* chore(language): folder cleanup - Remove unnecessary .DS_Store file - Update README.rst for Python 3.9+ * chore(language): update samples - Remove unused region tags. - Fixes for linter with types. - Apply Python Style Guide.
1 parent 09be61e commit 376b739

File tree

6 files changed

+16
-15
lines changed

6 files changed

+16
-15
lines changed
-6 KB
Binary file not shown.

language/snippets/cloud-client/v1/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Install Dependencies
4646
.. _Python Development Environment Setup Guide:
4747
https://cloud.google.com/python/setup
4848

49-
#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.
49+
#. Create a virtualenv. Samples are compatible with Python 3.9+.
5050

5151
.. code-block:: bash
5252

language/snippets/cloud-client/v1/quickstart.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,21 @@
1515
# limitations under the License.
1616

1717

18-
def run_quickstart():
18+
def run_quickstart() -> None:
1919
# [START language_quickstart]
20-
# Imports the Google Cloud client library
20+
# Imports the Google Cloud client library.
2121
from google.cloud import language_v1
2222

23-
# Instantiates a client
24-
# [START language_python_migration_client]
23+
# Instantiates a client.
2524
client = language_v1.LanguageServiceClient()
26-
# [END language_python_migration_client]
2725

28-
# The text to analyze
26+
# The text to analyze.
2927
text = "Hello, world!"
3028
document = language_v1.types.Document(
3129
content=text, type_=language_v1.types.Document.Type.PLAIN_TEXT
3230
)
3331

34-
# Detects the sentiment of the text
32+
# Detects the sentiment of the text.
3533
sentiment = client.analyze_sentiment(
3634
request={"document": document}
3735
).document_sentiment

language/snippets/cloud-client/v1/quickstart_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import pytest
1516

1617
import quickstart
1718

1819

19-
def test_quickstart(capsys):
20+
def test_quickstart(capsys: pytest.LogCaptureFixture) -> None:
2021
quickstart.run_quickstart()
2122
out, _ = capsys.readouterr()
2223
assert "Sentiment" in out

language/snippets/cloud-client/v1/set_endpoint.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@
1313
# limitations under the License.
1414

1515

16-
def set_endpoint():
17-
"""Change your endpoint"""
16+
def set_endpoint() -> None:
17+
"""Change your endpoint."""
1818
# [START language_set_endpoint]
1919
# Imports the Google Cloud client library
2020
from google.cloud import language_v1
2121

2222
client_options = {"api_endpoint": "eu-language.googleapis.com:443"}
2323

24-
# Instantiates a client
24+
# Instantiates a client.
2525
client = language_v1.LanguageServiceClient(client_options=client_options)
2626
# [END language_set_endpoint]
2727

28-
# The text to analyze
28+
# The text to analyze.
2929
document = language_v1.Document(
3030
content="Hello, world!", type_=language_v1.Document.Type.PLAIN_TEXT
3131
)
3232

33-
# Detects the sentiment of the text
33+
# Detects the sentiment of the text.
3434
sentiment = client.analyze_sentiment(
3535
request={"document": document}
3636
).document_sentiment

language/snippets/cloud-client/v1/set_endpoint_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import pytest
16+
1517
import set_endpoint
1618

1719

18-
def test_set_endpoint(capsys):
20+
def test_set_endpoint(capsys: pytest.LogCaptureFixture) -> None:
1921
set_endpoint.set_endpoint()
2022

2123
out, _ = capsys.readouterr()

0 commit comments

Comments
 (0)