From 71ec72dd3564f48c575154d79d65c30a5d826174 Mon Sep 17 00:00:00 2001 From: Emmanuel Alejandro Parada Licea Date: Wed, 19 Feb 2025 18:17:53 -0600 Subject: [PATCH 1/2] chore(language): folder cleanup - Remove unnecessary .DS_Store file - Update README.rst for Python 3.9+ --- language/snippets/cloud-client/.DS_Store | Bin 6148 -> 0 bytes language/snippets/cloud-client/v1/README.rst | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 language/snippets/cloud-client/.DS_Store diff --git a/language/snippets/cloud-client/.DS_Store b/language/snippets/cloud-client/.DS_Store deleted file mode 100644 index f344c851a0ee4f90f50741edcbb6236ebbbc354d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!A`{pJ@TK5l+$r=92a0ahvsOrXzLD-AJ zJA9_tJXH)nbRY%~4!+FJvKg5HW`G%3RR+wdX>F`(fm|0ezzqDF0XiQfDxqUA)u@gR z98?Q{m_xS`w5gY%9BI%om}q`|5!qLbhGr$adW`KG>lp@{#r$6`qDu@SWfEid#21KsjsJmF3xm%a2q`Ow4wopkZ oF4Z_sK|@`|7)w|2E~*mrOEM50gQ-UJpzx1?qJaly;7=L&02eA$o&W#< 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 From 2de7dee756f551cd45acef3278c7a79935ac0e99 Mon Sep 17 00:00:00 2001 From: Emmanuel Alejandro Parada Licea Date: Wed, 19 Feb 2025 18:19:10 -0600 Subject: [PATCH 2/2] chore(language): update samples - Remove unused region tags. - Fixes for linter with types. - Apply Python Style Guide. --- language/snippets/cloud-client/v1/quickstart.py | 12 +++++------- language/snippets/cloud-client/v1/quickstart_test.py | 3 ++- language/snippets/cloud-client/v1/set_endpoint.py | 10 +++++----- .../snippets/cloud-client/v1/set_endpoint_test.py | 4 +++- 4 files changed, 15 insertions(+), 14 deletions(-) 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()