diff --git a/language/snippets/cloud-client/.DS_Store b/language/snippets/cloud-client/.DS_Store deleted file mode 100644 index f344c851a0e..00000000000 Binary files a/language/snippets/cloud-client/.DS_Store and /dev/null differ diff --git a/language/snippets/cloud-client/v1/README.rst b/language/snippets/cloud-client/v1/README.rst index e0d719464c5..ba7efc9314f 100644 --- a/language/snippets/cloud-client/v1/README.rst +++ b/language/snippets/cloud-client/v1/README.rst @@ -46,7 +46,7 @@ Install Dependencies .. _Python Development Environment Setup Guide: https://cloud.google.com/python/setup -#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. +#. Create a virtualenv. Samples are compatible with Python 3.9+. .. code-block:: bash diff --git a/language/snippets/cloud-client/v1/quickstart.py b/language/snippets/cloud-client/v1/quickstart.py index f45d431164b..b61e59b2659 100644 --- a/language/snippets/cloud-client/v1/quickstart.py +++ b/language/snippets/cloud-client/v1/quickstart.py @@ -15,23 +15,21 @@ # limitations under the License. -def run_quickstart(): +def run_quickstart() -> None: # [START language_quickstart] - # Imports the Google Cloud client library + # Imports the Google Cloud client library. from google.cloud import language_v1 - # Instantiates a client - # [START language_python_migration_client] + # Instantiates a client. client = language_v1.LanguageServiceClient() - # [END language_python_migration_client] - # The text to analyze + # The text to analyze. text = "Hello, world!" document = language_v1.types.Document( content=text, type_=language_v1.types.Document.Type.PLAIN_TEXT ) - # Detects the sentiment of the text + # Detects the sentiment of the text. sentiment = client.analyze_sentiment( request={"document": document} ).document_sentiment diff --git a/language/snippets/cloud-client/v1/quickstart_test.py b/language/snippets/cloud-client/v1/quickstart_test.py index 065ff2f7409..e680aeebe21 100644 --- a/language/snippets/cloud-client/v1/quickstart_test.py +++ b/language/snippets/cloud-client/v1/quickstart_test.py @@ -12,11 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pytest import quickstart -def test_quickstart(capsys): +def test_quickstart(capsys: pytest.LogCaptureFixture) -> None: quickstart.run_quickstart() out, _ = capsys.readouterr() assert "Sentiment" in out diff --git a/language/snippets/cloud-client/v1/set_endpoint.py b/language/snippets/cloud-client/v1/set_endpoint.py index c93dee2591f..da56d42164f 100644 --- a/language/snippets/cloud-client/v1/set_endpoint.py +++ b/language/snippets/cloud-client/v1/set_endpoint.py @@ -13,24 +13,24 @@ # limitations under the License. -def set_endpoint(): - """Change your endpoint""" +def set_endpoint() -> None: + """Change your endpoint.""" # [START language_set_endpoint] # Imports the Google Cloud client library from google.cloud import language_v1 client_options = {"api_endpoint": "eu-language.googleapis.com:443"} - # Instantiates a client + # Instantiates a client. client = language_v1.LanguageServiceClient(client_options=client_options) # [END language_set_endpoint] - # The text to analyze + # The text to analyze. document = language_v1.Document( content="Hello, world!", type_=language_v1.Document.Type.PLAIN_TEXT ) - # Detects the sentiment of the text + # Detects the sentiment of the text. sentiment = client.analyze_sentiment( request={"document": document} ).document_sentiment diff --git a/language/snippets/cloud-client/v1/set_endpoint_test.py b/language/snippets/cloud-client/v1/set_endpoint_test.py index 817748b12be..e3bca43b6ce 100644 --- a/language/snippets/cloud-client/v1/set_endpoint_test.py +++ b/language/snippets/cloud-client/v1/set_endpoint_test.py @@ -12,10 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pytest + import set_endpoint -def test_set_endpoint(capsys): +def test_set_endpoint(capsys: pytest.LogCaptureFixture) -> None: set_endpoint.set_endpoint() out, _ = capsys.readouterr()