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

Commit

Permalink
chore: drop six (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Sep 22, 2021
1 parent c1cc5ea commit aa38acb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
10 changes: 4 additions & 6 deletions google/cloud/translate_v2/client.py
Expand Up @@ -15,8 +15,6 @@
"""Client for interacting with the Google Cloud Translation API."""


import six

import google.api_core.client_options
from google.cloud.client import Client as BaseClient

Expand Down Expand Up @@ -153,7 +151,7 @@ def detect_language(self, values):
in it.
"""
single_value = False
if isinstance(values, six.string_types):
if isinstance(values, str):
single_value = True
values = [values]

Expand Down Expand Up @@ -247,13 +245,13 @@ def translate(
values and translations differ.
"""
single_value = False
if isinstance(values, six.string_types):
if isinstance(values, str):
single_value = True
values = [values]

if target_language is None:
target_language = self.target_language
if isinstance(customization_ids, six.string_types):
if isinstance(customization_ids, str):
customization_ids = [customization_ids]

data = {
Expand All @@ -272,7 +270,7 @@ def translate(
raise ValueError(
"Expected iterations to have same length", values, translations
)
for value, translation in six.moves.zip(values, translations):
for value, translation in zip(values, translations):
translation["input"] = value

if single_value:
Expand Down
3 changes: 1 addition & 2 deletions samples/snippets/snippets.py
Expand Up @@ -85,12 +85,11 @@ def translate_text_with_model(target, text, model="nmt"):
Target must be an ISO 639-1 language code.
See https://g.co/cloud/translate/v2/translate-reference#supported_languages
"""
import six
from google.cloud import translate_v2 as translate

translate_client = translate.Client()

if isinstance(text, six.binary_type):
if isinstance(text, bytes):
text = text.decode("utf-8")

# Text can also be a sequence of strings, in which case this method
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/v2/test__http.py
Expand Up @@ -28,8 +28,8 @@ def _make_one(self, *args, **kw):
return self._get_target_class()(*args, **kw)

def test_build_api_url_no_extra_query_params(self):
from six.moves.urllib.parse import parse_qsl
from six.moves.urllib.parse import urlsplit
from urllib.parse import parse_qsl
from urllib.parse import urlsplit

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

def test_build_api_url_w_custom_endpoint(self):
from six.moves.urllib.parse import parse_qsl
from six.moves.urllib.parse import urlsplit
from urllib.parse import parse_qsl
from urllib.parse import urlsplit

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

def test_build_api_url_w_extra_query_params(self):
from six.moves.urllib.parse import parse_qsl
from six.moves.urllib.parse import urlsplit
from urllib.parse import parse_qsl
from urllib.parse import urlsplit

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

def test_build_api_url_w_extra_query_params_tuple(self):
from six.moves.urllib.parse import parse_qsl
from six.moves.urllib.parse import urlsplit
from urllib.parse import parse_qsl
from urllib.parse import urlsplit

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

0 comments on commit aa38acb

Please sign in to comment.