File tree Expand file tree Collapse file tree 6 files changed +16
-15
lines changed
language/snippets/cloud-client Expand file tree Collapse file tree 6 files changed +16
-15
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import pytest
1516
1617import 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
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import pytest
16+
1517import 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 ()
You can’t perform that action at this time.
0 commit comments