Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit aa38acb

Browse files
authored
chore: drop six (#253)
1 parent c1cc5ea commit aa38acb

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

google/cloud/translate_v2/client.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
"""Client for interacting with the Google Cloud Translation API."""
1616

1717

18-
import six
19-
2018
import google.api_core.client_options
2119
from google.cloud.client import Client as BaseClient
2220

@@ -153,7 +151,7 @@ def detect_language(self, values):
153151
in it.
154152
"""
155153
single_value = False
156-
if isinstance(values, six.string_types):
154+
if isinstance(values, str):
157155
single_value = True
158156
values = [values]
159157

@@ -247,13 +245,13 @@ def translate(
247245
values and translations differ.
248246
"""
249247
single_value = False
250-
if isinstance(values, six.string_types):
248+
if isinstance(values, str):
251249
single_value = True
252250
values = [values]
253251

254252
if target_language is None:
255253
target_language = self.target_language
256-
if isinstance(customization_ids, six.string_types):
254+
if isinstance(customization_ids, str):
257255
customization_ids = [customization_ids]
258256

259257
data = {
@@ -272,7 +270,7 @@ def translate(
272270
raise ValueError(
273271
"Expected iterations to have same length", values, translations
274272
)
275-
for value, translation in six.moves.zip(values, translations):
273+
for value, translation in zip(values, translations):
276274
translation["input"] = value
277275

278276
if single_value:

samples/snippets/snippets.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,11 @@ def translate_text_with_model(target, text, model="nmt"):
8585
Target must be an ISO 639-1 language code.
8686
See https://g.co/cloud/translate/v2/translate-reference#supported_languages
8787
"""
88-
import six
8988
from google.cloud import translate_v2 as translate
9089

9190
translate_client = translate.Client()
9291

93-
if isinstance(text, six.binary_type):
92+
if isinstance(text, bytes):
9493
text = text.decode("utf-8")
9594

9695
# Text can also be a sequence of strings, in which case this method

tests/unit/v2/test__http.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def _make_one(self, *args, **kw):
2828
return self._get_target_class()(*args, **kw)
2929

3030
def test_build_api_url_no_extra_query_params(self):
31-
from six.moves.urllib.parse import parse_qsl
32-
from six.moves.urllib.parse import urlsplit
31+
from urllib.parse import parse_qsl
32+
from urllib.parse import urlsplit
3333

3434
conn = self._make_one(object())
3535
uri = conn.build_api_url("/foo")
@@ -44,8 +44,8 @@ def test_build_api_url_no_extra_query_params(self):
4444
self.assertEqual(parms, {})
4545

4646
def test_build_api_url_w_custom_endpoint(self):
47-
from six.moves.urllib.parse import parse_qsl
48-
from six.moves.urllib.parse import urlsplit
47+
from urllib.parse import parse_qsl
48+
from urllib.parse import urlsplit
4949

5050
custom_endpoint = "https://foo-translation.googleapis.com"
5151
conn = self._make_one(object(), api_endpoint=custom_endpoint)
@@ -61,8 +61,8 @@ def test_build_api_url_w_custom_endpoint(self):
6161
self.assertEqual(parms, {})
6262

6363
def test_build_api_url_w_extra_query_params(self):
64-
from six.moves.urllib.parse import parse_qsl
65-
from six.moves.urllib.parse import urlsplit
64+
from urllib.parse import parse_qsl
65+
from urllib.parse import urlsplit
6666

6767
conn = self._make_one(object())
6868
uri = conn.build_api_url("/foo", {"bar": "baz"})
@@ -75,8 +75,8 @@ def test_build_api_url_w_extra_query_params(self):
7575
self.assertEqual(parms["bar"], "baz")
7676

7777
def test_build_api_url_w_extra_query_params_tuple(self):
78-
from six.moves.urllib.parse import parse_qsl
79-
from six.moves.urllib.parse import urlsplit
78+
from urllib.parse import parse_qsl
79+
from urllib.parse import urlsplit
8080

8181
conn = self._make_one(object())
8282
query_params = [("q", "val1"), ("q", "val2")]

0 commit comments

Comments
 (0)