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

Commit f615aee

Browse files
committed
Fixing lint issues
1 parent 21196fd commit f615aee

9 files changed

Lines changed: 25 additions & 27 deletions

google/auth/_regional_access_boundary_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ def run(self):
6565
"Asynchronous Regional Access Boundary lookup failed. Entering cooldown."
6666
)
6767
self._credentials._regional_access_boundary_cooldown_expiry = (
68-
_helpers.utcnow()
69-
+ self._credentials._current_rab_cooldown_duration
68+
_helpers.utcnow() + self._credentials._current_rab_cooldown_duration
7069
)
7170
new_cooldown_duration = (
7271
self._credentials._current_rab_cooldown_duration * 2

google/auth/compute_engine/credentials.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import datetime
2323
import logging
2424

25-
_LOGGER = logging.getLogger(__name__)
26-
2725
from google.auth import _constants
2826
from google.auth import _helpers
2927
from google.auth import credentials
@@ -34,6 +32,8 @@
3432
from google.auth.compute_engine import _metadata
3533
from google.oauth2 import _client
3634

35+
_LOGGER = logging.getLogger(__name__)
36+
3737

3838
class Credentials(
3939
credentials.Scoped,

google/auth/credentials.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,18 @@
1616
"""Interfaces for credentials."""
1717

1818
import abc
19-
import datetime
2019
from enum import Enum
2120
import logging
2221
import os
2322
import threading
2423
from urllib.parse import urlparse
25-
import warnings
2624

27-
from google.auth import _exponential_backoff
2825
from google.auth import _helpers, environment_vars
26+
from google.auth import _regional_access_boundary_utils
2927
from google.auth import exceptions
3028
from google.auth import metrics
3129
from google.auth._credentials_base import _BaseCredentials
3230
from google.auth._refresh_worker import RefreshThreadManager
33-
from google.auth import _regional_access_boundary_utils
3431

3532
DEFAULT_UNIVERSE_DOMAIN = "googleapis.com"
3633

@@ -326,7 +323,10 @@ def _perform_refresh_token(self, request):
326323
def _with_regional_access_boundary(self, regional_access_boundary):
327324
"""Returns a copy of these credentials with a modified Regional Access Boundary.
328325
This is an internal method used by credential factory methods (e.g., from_info)
329-
to seed the RAB cache. The provided value is cached with the default TTL.
326+
to seed the RAB cache when a new boundary is fetched or explicitly provided.
327+
Because this represents a newly acquired boundary, it is granted a fresh
328+
default TTL and any previous cooldowns are cleared. To copy an existing boundary's
329+
state (including its remaining TTL and cooldowns), use `_copy_regional_access_boundary_state`.
330330
Args:
331331
regional_access_boundary (dict): Must contain an "encodedLocations" key.
332332
Returns:

google/auth/external_account.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,8 @@
3434
import functools
3535
import io
3636
import json
37-
import re
38-
import warnings
39-
4037
import logging
41-
42-
_LOGGER = logging.getLogger(__name__)
38+
import re
4339

4440
from google.auth import _constants
4541
from google.auth import _helpers
@@ -50,6 +46,8 @@
5046
from google.oauth2 import sts
5147
from google.oauth2 import utils
5248

49+
_LOGGER = logging.getLogger(__name__)
50+
5351
# External account JSON type identifier.
5452
_EXTERNAL_ACCOUNT_JSON_TYPE = "external_account"
5553
# The token exchange grant_type used for exchanging credentials.

google/auth/external_account_authorized_user.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,8 @@
3636
import datetime
3737
import io
3838
import json
39-
import re
40-
import warnings
41-
4239
import logging
43-
44-
_LOGGER = logging.getLogger(__name__)
40+
import re
4541

4642
from google.auth import _constants
4743
from google.auth import _helpers
@@ -50,6 +46,8 @@
5046
from google.oauth2 import sts
5147
from google.oauth2 import utils
5248

49+
_LOGGER = logging.getLogger(__name__)
50+
5351
_EXTERNAL_ACCOUNT_AUTHORIZED_USER_JSON_TYPE = "external_account_authorized_user"
5452

5553

google/auth/impersonated_credentials.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,18 @@
3030
from datetime import datetime
3131
import http.client as http_client
3232
import json
33-
import warnings
33+
import logging
3434

35+
from google.auth import _constants
3536
from google.auth import _exponential_backoff
3637
from google.auth import _helpers
3738
from google.auth import credentials
3839
from google.auth import exceptions
3940
from google.auth import iam
4041
from google.auth import jwt
4142
from google.auth import metrics
42-
from google.auth import _constants
4343
from google.oauth2 import _client
4444

45-
import logging
46-
4745
_LOGGER = logging.getLogger(__name__)
4846

4947
_REFRESH_ERROR = "Unable to acquire impersonated credentials"

google/oauth2/_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
import datetime
2727
import http.client as http_client
2828
import json
29-
import urllib
30-
3129
import logging
30+
import urllib
3231

3332
from google.auth import _exponential_backoff
3433
from google.auth import _helpers

google/oauth2/_service_account_async.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ async def refresh(self, request):
7575
self.token = access_token
7676
self.expiry = expiry
7777

78+
@_helpers.copy_docstring(credentials_async.Credentials)
79+
async def before_request(self, request, method, url, headers):
80+
await credentials_async.Credentials.before_request(
81+
self, request, method, url, headers
82+
)
83+
self._maybe_start_regional_access_boundary_refresh(request, url)
84+
7885

7986
class IDTokenCredentials(
8087
service_account.IDTokenCredentials,

google/oauth2/service_account.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272

7373
import copy
7474
import datetime
75+
import logging
7576

7677
from google.auth import _constants
7778
from google.auth import _helpers
@@ -83,8 +84,6 @@
8384
from google.auth import metrics
8485
from google.oauth2 import _client
8586

86-
import logging
87-
8887
_LOGGER = logging.getLogger(__name__)
8988

9089
_DEFAULT_TOKEN_LIFETIME_SECS = 3600 # 1 hour in seconds

0 commit comments

Comments
 (0)