fix!: drop support for Python 2.7 (#778)
Drop use of 'six' wrapper library.
Drop 'u"' prefixes.
Drop support for app_engine 'classic' mode (Python 2.7-only).
Release-As: 2.0.0b1
Closes #777.
diff --git a/google/auth/_helpers.py b/google/auth/_helpers.py
index 21c987a..09f32f8 100644
--- a/google/auth/_helpers.py
+++ b/google/auth/_helpers.py
@@ -17,9 +17,7 @@
import base64
import calendar
import datetime
-
-import six
-from six.moves import urllib
+import urllib
CLOCK_SKEW_SECS = 10 # 10 seconds
@@ -84,9 +82,6 @@
def to_bytes(value, encoding="utf-8"):
"""Converts a string value to bytes, if necessary.
- Unfortunately, ``six.b`` is insufficient for this task since in
- Python 2 because it does not modify ``unicode`` objects.
-
Args:
value (Union[str, bytes]): The value to be converted.
encoding (str): The encoding to use to convert unicode to bytes.
@@ -99,8 +94,8 @@
Raises:
ValueError: If the value could not be converted to bytes.
"""
- result = value.encode(encoding) if isinstance(value, six.text_type) else value
- if isinstance(result, six.binary_type):
+ result = value.encode(encoding) if isinstance(value, str) else value
+ if isinstance(result, bytes):
return result
else:
raise ValueError("{0!r} could not be converted to bytes".format(value))
@@ -119,8 +114,8 @@
Raises:
ValueError: If the value could not be converted to unicode.
"""
- result = value.decode("utf-8") if isinstance(value, six.binary_type) else value
- if isinstance(result, six.text_type):
+ result = value.decode("utf-8") if isinstance(value, bytes) else value
+ if isinstance(result, str):
return result
else:
raise ValueError("{0!r} could not be converted to unicode".format(value))
@@ -162,7 +157,7 @@
query_params.update(params)
# Remove any values specified in remove.
query_params = {
- key: value for key, value in six.iteritems(query_params) if key not in remove
+ key: value for key, value in query_params.items() if key not in remove
}
# Re-encoded the query string.
new_query = urllib.parse.urlencode(query_params, doseq=True)