Skip to content

Commit de32347

Browse files
authored
chore: update default python version for tests to 3.14 (#1892)
Also update the `docs` session to 3.10 to match the Python GAPIC code generator used to generate Cloud Client libraries: https://github.com/googleapis/gapic-generator-python/blob/d20dd2876fbf8c35f6a994639864815b0d7608ab/gapic/templates/noxfile.py.j2#L360-L361 Also update black to 23.7.0 to resolve the following stack trace ``` nox > python -m pip install flake8 flake8-import-order docutils click==8.0.4 black==19.3b0 nox > python -m pip install -e . nox > black --check google tests tests_async noxfile.py setup.py docs/conf.py Traceback (most recent call last): File "/tmpfs/src/github/google-auth-library-python/.nox/lint/bin/black", line 8, in <module> sys.exit(patched_main()) ~~~~~~~~~~~~^^ File "/tmpfs/src/github/google-auth-library-python/.nox/lint/lib/python3.14/site-packages/black.py", line 3754, in patched_main main() ~~~~^^ File "/tmpfs/src/github/google-auth-library-python/.nox/lint/lib/python3.14/site-packages/click/core.py", line 1128, in __call__ return self.main(*args, **kwargs) ~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/tmpfs/src/github/google-auth-library-python/.nox/lint/lib/python3.14/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/tmpfs/src/github/google-auth-library-python/.nox/lint/lib/python3.14/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmpfs/src/github/google-auth-library-python/.nox/lint/lib/python3.14/site-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "/tmpfs/src/github/google-auth-library-python/.nox/lint/lib/python3.14/site-packages/click/decorators.py", line 26, in new_func return f(get_current_context(), *args, **kwargs) File "/tmpfs/src/github/google-auth-library-python/.nox/lint/lib/python3.14/site-packages/black.py", line 434, in main loop = asyncio.get_event_loop() File "/usr/local/lib/python3.14/asyncio/events.py", line 715, in get_event_loop raise RuntimeError('There is no current event loop in thread %r.' % threading.current_thread().name) RuntimeError: There is no current event loop in thread 'MainThread'. nox > Command black --check google tests tests_async noxfile.py setup.py docs/conf.py failed with exit code 1 ``` This PR also fixes the coverage presubmit to append the coverage check to run across python runtimes.
1 parent 02e7163 commit de32347

Some content is hidden

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

41 files changed

+150
-123
lines changed

google/auth/_cloud_sdk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def get_application_default_credentials_path():
8383

8484

8585
def _run_subprocess_ignore_stderr(command):
86-
""" Return subprocess.check_output with the given command and ignores stderr."""
86+
"""Return subprocess.check_output with the given command and ignores stderr."""
8787
with open(os.devnull, "w") as devnull:
8888
output = subprocess.check_output(command, stderr=devnull)
8989
return output

google/auth/_default.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,10 @@ def _get_impersonated_service_account_credentials(filename, info, scopes):
538538
from google.auth import impersonated_credentials
539539

540540
try:
541-
credentials = impersonated_credentials.Credentials.from_impersonated_service_account_info(
542-
info, scopes=scopes
541+
credentials = (
542+
impersonated_credentials.Credentials.from_impersonated_service_account_info(
543+
info, scopes=scopes
544+
)
543545
)
544546
except ValueError as caught_exc:
545547
msg = "Failed to load impersonated service account credentials from {}".format(
@@ -554,8 +556,8 @@ def _get_gdch_service_account_credentials(filename, info):
554556
from google.oauth2 import gdch_credentials
555557

556558
try:
557-
credentials = gdch_credentials.ServiceAccountCredentials.from_service_account_info(
558-
info
559+
credentials = (
560+
gdch_credentials.ServiceAccountCredentials.from_service_account_info(info)
559561
)
560562
except ValueError as caught_exc:
561563
msg = "Failed to load GDCH service account credentials from {}".format(filename)

google/auth/_refresh_worker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def start_refresh(self, cred, request):
6161

6262
def clear_error(self):
6363
"""
64-
Removes any errors that were stored from previous background refreshes.
65-
"""
64+
Removes any errors that were stored from previous background refreshes.
65+
"""
6666
with self._lock:
6767
if self._worker:
6868
self._worker._error_info = None

google/auth/aws.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,10 @@ def _generate_authentication_header_map(
348348
class AwsSecurityCredentials:
349349
"""A class that models AWS security credentials with an optional session token.
350350
351-
Attributes:
352-
access_key_id (str): The AWS security credentials access key id.
353-
secret_access_key (str): The AWS security credentials secret access key.
354-
session_token (Optional[str]): The optional AWS security credentials session token. This should be set when using temporary credentials.
351+
Attributes:
352+
access_key_id (str): The AWS security credentials access key id.
353+
secret_access_key (str): The AWS security credentials secret access key.
354+
session_token (Optional[str]): The optional AWS security credentials session token. This should be set when using temporary credentials.
355355
"""
356356

357357
access_key_id: str
@@ -420,7 +420,6 @@ def __init__(self, credential_source):
420420

421421
@_helpers.copy_docstring(AwsSecurityCredentialsSupplier)
422422
def get_aws_security_credentials(self, context, request):
423-
424423
# Check environment variables for permanent credentials first.
425424
# https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html
426425
env_aws_access_key_id = os.environ.get(environment_vars.AWS_ACCESS_KEY_ID)
@@ -688,8 +687,8 @@ def __init__(
688687
)
689688
else:
690689
environment_id = credential_source.get("environment_id") or ""
691-
self._aws_security_credentials_supplier = _DefaultAwsSecurityCredentialsSupplier(
692-
credential_source
690+
self._aws_security_credentials_supplier = (
691+
_DefaultAwsSecurityCredentialsSupplier(credential_source)
693692
)
694693
self._cred_verification_url = credential_source.get(
695694
"regional_cred_verification_url"
@@ -759,8 +758,10 @@ def retrieve_subject_token(self, request):
759758

760759
# Retrieve the AWS security credentials needed to generate the signed
761760
# request.
762-
aws_security_credentials = self._aws_security_credentials_supplier.get_aws_security_credentials(
763-
self._supplier_context, request
761+
aws_security_credentials = (
762+
self._aws_security_credentials_supplier.get_aws_security_credentials(
763+
self._supplier_context, request
764+
)
764765
)
765766
# Generate the signed request to AWS STS GetCallerIdentity API.
766767
# Use the required regional endpoint. Otherwise, the request will fail.

google/auth/compute_engine/credentials.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ def with_target_audience(self, target_audience):
399399

400400
@_helpers.copy_docstring(credentials.CredentialsWithQuotaProject)
401401
def with_quota_project(self, quota_project_id):
402-
403402
# since the signer is already instantiated,
404403
# the request is not needed
405404
if self._use_metadata_identity_endpoint:
@@ -423,7 +422,6 @@ def with_quota_project(self, quota_project_id):
423422

424423
@_helpers.copy_docstring(credentials.CredentialsWithTokenUri)
425424
def with_token_uri(self, token_uri):
426-
427425
# since the signer is already instantiated,
428426
# the request is not needed
429427
if self._use_metadata_identity_endpoint:

google/auth/external_account.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ class Credentials(
9898
is used.
9999
When the credential configuration is accepted from an
100100
untrusted source, you should validate it before using.
101-
Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details."""
101+
Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details.
102+
"""
102103

103104
def __init__(
104105
self,

google/auth/external_account_authorized_user.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ class Credentials(
7070
is used.
7171
When the credential configuration is accepted from an
7272
untrusted source, you should validate it before using.
73-
Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details."""
73+
Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details.
74+
"""
7475

7576
def __init__(
7677
self,

google/auth/identity_pool.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,17 @@ def get_subject_token(self, context, request):
8383

8484
class _TokenContent(NamedTuple):
8585
"""Models the token content response from file and url internal suppliers.
86-
Attributes:
87-
content (str): The string content of the file or URL response.
88-
location (str): The location the content was retrieved from. This will either be a file location or a URL.
86+
Attributes:
87+
content (str): The string content of the file or URL response.
88+
location (str): The location the content was retrieved from. This will either be a file location or a URL.
8989
"""
9090

9191
content: str
9292
location: str
9393

9494

9595
class _FileSupplier(SubjectTokenSupplier):
96-
""" Internal implementation of subject token supplier which supports reading a subject token from a file."""
96+
"""Internal implementation of subject token supplier which supports reading a subject token from a file."""
9797

9898
def __init__(self, path, format_type, subject_token_field_name):
9999
self._path = path
@@ -114,7 +114,7 @@ def get_subject_token(self, context, request):
114114

115115

116116
class _UrlSupplier(SubjectTokenSupplier):
117-
""" Internal implementation of subject token supplier which supports retrieving a subject token by calling a URL endpoint."""
117+
"""Internal implementation of subject token supplier which supports retrieving a subject token by calling a URL endpoint."""
118118

119119
def __init__(self, url, format_type, subject_token_field_name, headers):
120120
self._url = url
@@ -261,7 +261,8 @@ class Credentials(external_account.Credentials):
261261
is used.
262262
When the credential configuration is accepted from an
263263
untrusted source, you should validate it before using.
264-
Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details."""
264+
Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details.
265+
"""
265266

266267
def __init__(
267268
self,
@@ -566,8 +567,8 @@ def refresh(self, request):
566567
cert_bytes = self._get_cert_bytes()
567568
cert = _agent_identity_utils.parse_certificate(cert_bytes)
568569
if _agent_identity_utils.should_request_bound_token(cert):
569-
cert_fingerprint = _agent_identity_utils.calculate_certificate_fingerprint(
570-
cert
570+
cert_fingerprint = (
571+
_agent_identity_utils.calculate_certificate_fingerprint(cert)
571572
)
572573

573574
self._refresh_token(request, cert_fingerprint=cert_fingerprint)

google/auth/jwt.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ def signer(self):
586586

587587
@property # type: ignore
588588
def additional_claims(self):
589-
""" Additional claims the JWT object was created with."""
589+
"""Additional claims the JWT object was created with."""
590590
return self._additional_claims
591591

592592

@@ -760,7 +760,6 @@ def with_claims(self, issuer=None, subject=None, additional_claims=None):
760760

761761
@_helpers.copy_docstring(google.auth.credentials.CredentialsWithQuotaProject)
762762
def with_quota_project(self, quota_project_id):
763-
764763
return self.__class__(
765764
self._signer,
766765
issuer=self._issuer,

google/auth/metrics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def python_and_auth_lib_version():
4848

4949
# Token request metric header values
5050

51+
5152
# x-goog-api-client header value for access token request via metadata server.
5253
# Example: "gl-python/3.7 auth/1.1 auth-request-type/at cred-type/mds"
5354
def token_request_access_token_mds():
@@ -108,6 +109,7 @@ def token_request_user():
108109

109110
# Miscellenous metrics
110111

112+
111113
# x-goog-api-client header value for metadata server ping.
112114
# Example: "gl-python/3.7 auth/1.1 auth-request-type/mds"
113115
def mds_ping():

0 commit comments

Comments
 (0)