Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit 2b6a2cf

Browse files
authored
1 parent 2885211 commit 2b6a2cf

66 files changed

Lines changed: 163 additions & 286 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

google/auth/_cloud_sdk.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import os
1818
import subprocess
1919

20-
import six
21-
2220
from google.auth import _helpers
2321
from google.auth import environment_vars
2422
from google.auth import exceptions
@@ -152,4 +150,4 @@ def get_auth_access_token(account=None):
152150
new_exc = exceptions.UserAccessTokenError(
153151
"Failed to obtain access token", caught_exc
154152
)
155-
six.raise_from(new_exc, caught_exc)
153+
raise new_exc from caught_exc

google/auth/_credentials_async.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@
1818
import abc
1919
import inspect
2020

21-
import six
22-
2321
from google.auth import credentials
2422

2523

26-
@six.add_metaclass(abc.ABCMeta)
27-
class Credentials(credentials.Credentials):
24+
class Credentials(credentials.Credentials, metaclass=abc.ABCMeta):
2825
"""Async inherited credentials class from google.auth.credentials.
2926
The added functionality is the before_request call which requires
3027
async/await syntax.
@@ -84,8 +81,7 @@ class AnonymousCredentials(credentials.AnonymousCredentials, Credentials):
8481
"""
8582

8683

87-
@six.add_metaclass(abc.ABCMeta)
88-
class ReadOnlyScoped(credentials.ReadOnlyScoped):
84+
class ReadOnlyScoped(credentials.ReadOnlyScoped, metaclass=abc.ABCMeta):
8985
"""Interface for credentials whose scopes can be queried.
9086
9187
OAuth 2.0-based credentials allow limiting access using scopes as described
@@ -171,6 +167,5 @@ def with_scopes_if_required(credentials, scopes):
171167
return credentials
172168

173169

174-
@six.add_metaclass(abc.ABCMeta)
175-
class Signing(credentials.Signing):
170+
class Signing(credentials.Signing, metaclass=abc.ABCMeta):
176171
"""Interface for credentials that can cryptographically sign messages."""

google/auth/_default.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import os
2424
import warnings
2525

26-
import six
27-
2826
from google.auth import environment_vars
2927
from google.auth import exceptions
3028
import google.auth.transport._http_client
@@ -124,7 +122,7 @@ def load_credentials_from_file(
124122
new_exc = exceptions.DefaultCredentialsError(
125123
"File {} is not a valid json file.".format(filename), caught_exc
126124
)
127-
six.raise_from(new_exc, caught_exc)
125+
raise new_exc from caught_exc
128126
return _load_credentials_from_info(
129127
filename, info, scopes, default_scopes, quota_project_id, request
130128
)
@@ -440,7 +438,7 @@ def _get_authorized_user_credentials(filename, info, scopes=None):
440438
except ValueError as caught_exc:
441439
msg = "Failed to load authorized user credentials from {}".format(filename)
442440
new_exc = exceptions.DefaultCredentialsError(msg, caught_exc)
443-
six.raise_from(new_exc, caught_exc)
441+
raise new_exc from caught_exc
444442
return credentials, None
445443

446444

@@ -454,7 +452,7 @@ def _get_service_account_credentials(filename, info, scopes=None, default_scopes
454452
except ValueError as caught_exc:
455453
msg = "Failed to load service account credentials from {}".format(filename)
456454
new_exc = exceptions.DefaultCredentialsError(msg, caught_exc)
457-
six.raise_from(new_exc, caught_exc)
455+
raise new_exc from caught_exc
458456
return credentials, info.get("project_id")
459457

460458

@@ -500,7 +498,7 @@ def _get_impersonated_service_account_credentials(filename, info, scopes):
500498
filename
501499
)
502500
new_exc = exceptions.DefaultCredentialsError(msg, caught_exc)
503-
six.raise_from(new_exc, caught_exc)
501+
raise new_exc from caught_exc
504502
return credentials, None
505503

506504

@@ -514,7 +512,7 @@ def _get_gdch_service_account_credentials(filename, info):
514512
except ValueError as caught_exc:
515513
msg = "Failed to load GDCH service account credentials from {}".format(filename)
516514
new_exc = exceptions.DefaultCredentialsError(msg, caught_exc)
517-
six.raise_from(new_exc, caught_exc)
515+
raise new_exc from caught_exc
518516
return credentials, info.get("project")
519517

520518

google/auth/_default_async.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import json
2222
import os
2323

24-
import six
25-
2624
from google.auth import _default
2725
from google.auth import environment_vars
2826
from google.auth import exceptions
@@ -63,7 +61,7 @@ def load_credentials_from_file(filename, scopes=None, quota_project_id=None):
6361
new_exc = exceptions.DefaultCredentialsError(
6462
"File {} is not a valid json file.".format(filename), caught_exc
6563
)
66-
six.raise_from(new_exc, caught_exc)
64+
raise new_exc from caught_exc
6765

6866
# The type key should indicate that the file is either a service account
6967
# credentials file or an authorized user credentials file.
@@ -79,7 +77,7 @@ def load_credentials_from_file(filename, scopes=None, quota_project_id=None):
7977
except ValueError as caught_exc:
8078
msg = "Failed to load authorized user credentials from {}".format(filename)
8179
new_exc = exceptions.DefaultCredentialsError(msg, caught_exc)
82-
six.raise_from(new_exc, caught_exc)
80+
raise new_exc from caught_exc
8381
if quota_project_id:
8482
credentials = credentials.with_quota_project(quota_project_id)
8583
if not credentials.quota_project_id:
@@ -96,7 +94,7 @@ def load_credentials_from_file(filename, scopes=None, quota_project_id=None):
9694
except ValueError as caught_exc:
9795
msg = "Failed to load service account credentials from {}".format(filename)
9896
new_exc = exceptions.DefaultCredentialsError(msg, caught_exc)
99-
six.raise_from(new_exc, caught_exc)
97+
raise new_exc from caught_exc
10098
return credentials, info.get("project_id")
10199

102100
else:

google/auth/_exponential_backoff.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import random
1616
import time
1717

18-
import six
19-
2018
# The default amount of retry attempts
2119
_DEFAULT_RETRY_TOTAL_ATTEMPTS = 3
2220

@@ -38,7 +36,7 @@
3836
"""
3937

4038

41-
class ExponentialBackoff(six.Iterator):
39+
class ExponentialBackoff:
4240
"""An exponential backoff iterator. This can be used in a for loop to
4341
perform requests with exponential backoff.
4442

google/auth/_helpers.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
import calendar
1919
import datetime
2020
import sys
21-
22-
import six
23-
from six.moves import urllib
21+
import urllib
2422

2523
from google.auth import exceptions
2624

@@ -89,9 +87,6 @@ def datetime_to_secs(value):
8987
def to_bytes(value, encoding="utf-8"):
9088
"""Converts a string value to bytes, if necessary.
9189
92-
Unfortunately, ``six.b`` is insufficient for this task since in
93-
Python 2 because it does not modify ``unicode`` objects.
94-
9590
Args:
9691
value (Union[str, bytes]): The value to be converted.
9792
encoding (str): The encoding to use to convert unicode to bytes.
@@ -104,8 +99,8 @@ def to_bytes(value, encoding="utf-8"):
10499
Raises:
105100
google.auth.exceptions.InvalidValue: If the value could not be converted to bytes.
106101
"""
107-
result = value.encode(encoding) if isinstance(value, six.text_type) else value
108-
if isinstance(result, six.binary_type):
102+
result = value.encode(encoding) if isinstance(value, str) else value
103+
if isinstance(result, bytes):
109104
return result
110105
else:
111106
raise exceptions.InvalidValue(
@@ -126,8 +121,8 @@ def from_bytes(value):
126121
Raises:
127122
google.auth.exceptions.InvalidValue: If the value could not be converted to unicode.
128123
"""
129-
result = value.decode("utf-8") if isinstance(value, six.binary_type) else value
130-
if isinstance(result, six.text_type):
124+
result = value.decode("utf-8") if isinstance(value, bytes) else value
125+
if isinstance(result, str):
131126
return result
132127
else:
133128
raise exceptions.InvalidValue(
@@ -171,7 +166,7 @@ def update_query(url, params, remove=None):
171166
query_params.update(params)
172167
# Remove any values specified in remove.
173168
query_params = {
174-
key: value for key, value in six.iteritems(query_params) if key not in remove
169+
key: value for key, value in query_params.items() if key not in remove
175170
}
176171
# Re-encoded the query string.
177172
new_query = urllib.parse.urlencode(query_params, doseq=True)

google/auth/_oauth2client.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
from __future__ import absolute_import
2323

24-
import six
25-
2624
from google.auth import _helpers
2725
import google.auth.app_engine
2826
import google.auth.compute_engine
@@ -34,7 +32,7 @@
3432
import oauth2client.contrib.gce # type: ignore
3533
import oauth2client.service_account # type: ignore
3634
except ImportError as caught_exc:
37-
six.raise_from(ImportError("oauth2client is not installed."), caught_exc)
35+
raise ImportError("oauth2client is not installed.") from caught_exc
3836

3937
try:
4038
import oauth2client.contrib.appengine # type: ignore
@@ -166,4 +164,4 @@ def convert(credentials):
166164
return _CLASS_CONVERSION_MAP[credentials_class](credentials)
167165
except KeyError as caught_exc:
168166
new_exc = ValueError(_CONVERT_ERROR_TMPL.format(credentials_class))
169-
six.raise_from(new_exc, caught_exc)
167+
raise new_exc from caught_exc

google/auth/_service_account_info.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import io
1818
import json
1919

20-
import six
21-
2220
from google.auth import crypt
2321
from google.auth import exceptions
2422

@@ -46,7 +44,7 @@ def from_dict(data, require=None, use_rsa_signer=True):
4644
"""
4745
keys_needed = set(require if require is not None else [])
4846

49-
missing = keys_needed.difference(six.iterkeys(data))
47+
missing = keys_needed.difference(data.keys())
5048

5149
if missing:
5250
raise exceptions.MalformedError(

google/auth/aws.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@
3939

4040
import hashlib
4141
import hmac
42+
import http.client as http_client
4243
import json
4344
import os
4445
import posixpath
4546
import re
46-
47-
from six.moves import http_client
48-
from six.moves import urllib
49-
from six.moves.urllib.parse import urljoin
47+
import urllib
48+
from urllib.parse import urljoin
5049

5150
from google.auth import _helpers
5251
from google.auth import environment_vars

google/auth/compute_engine/_metadata.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@
1818
"""
1919

2020
import datetime
21+
import http.client as http_client
2122
import json
2223
import logging
2324
import os
24-
25-
import six
26-
from six.moves import http_client
27-
from six.moves.urllib import parse as urlparse
25+
from urllib.parse import urljoin
2826

2927
from google.auth import _helpers
3028
from google.auth import environment_vars
@@ -185,7 +183,7 @@ def get(
185183
google.auth.exceptions.TransportError: if an error occurred while
186184
retrieving metadata.
187185
"""
188-
base_url = urlparse.urljoin(root, path)
186+
base_url = urljoin(root, path)
189187
query_params = {} if params is None else params
190188

191189
headers_to_use = _METADATA_HEADERS.copy()
@@ -228,7 +226,7 @@ def get(
228226
"Received invalid JSON from the Google Compute Engine "
229227
"metadata service: {:.20}".format(content)
230228
)
231-
six.raise_from(new_exc, caught_exc)
229+
raise new_exc from caught_exc
232230
else:
233231
return content
234232
else:

0 commit comments

Comments
 (0)