Skip to content

Commit 6eaa6be

Browse files
committed
lint
1 parent eb04044 commit 6eaa6be

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/toolbox-core/src/toolbox_core/auth_methods.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@
2424
URL = "https://toolbox-service-url"
2525
async with ToolboxClient(
2626
URL,
27-
client_headers={"Authorization": auth_methods.aget_google_id_token})
27+
client_headers={"Authorization": auth_methods.aget_google_id_token})
2828
as toolbox:
2929
tools = await toolbox.load_toolset()
3030
"""
3131

3232
import asyncio
3333
from datetime import datetime, timedelta, timezone
34-
from typing import Any, Dict, Optional, Callable, Coroutine
34+
from typing import Any, Callable, Coroutine, Dict, Optional
3535

36-
import google.auth
3736
from google.auth.exceptions import GoogleAuthError
3837
from google.auth.transport.requests import AuthorizedSession, Request
3938
from google.oauth2 import id_token
@@ -87,7 +86,8 @@ def _update_cache(new_token: str) -> None:
8786
_token_cache["token"] = None
8887
_token_cache["expires_at"] = datetime.min.replace(tzinfo=timezone.utc)
8988
raise ValueError(f"Failed to validate and cache the new token: {e}") from e
90-
89+
90+
9191
def get_google_token_from_aud(audience: Optional[str] = None) -> str:
9292
if _is_token_valid():
9393
return BEARER_TOKEN_PREFIX + _token_cache["token"]
@@ -140,13 +140,16 @@ def get_google_id_token(audience: Optional[str] = None) -> Callable[[], str]:
140140
GoogleAuthError: If fetching credentials or the token fails.
141141
ValueError: If the fetched token is invalid.
142142
"""
143+
143144
def _token_getter() -> str:
144145
return get_google_token_from_aud(audience)
145146

146147
return _token_getter
147148

148149

149-
def aget_google_id_token(audience: Optional[str] = None) -> Callable[[], Coroutine[Any, Any, str]]:
150+
def aget_google_id_token(
151+
audience: Optional[str] = None,
152+
) -> Callable[[], Coroutine[Any, Any, str]]:
150153
"""
151154
Returns an ASYNC function that, when called, fetches a Google ID token.
152155
This function uses Application Default Credentials for local systems
@@ -163,7 +166,8 @@ def aget_google_id_token(audience: Optional[str] = None) -> Callable[[], Corouti
163166
GoogleAuthError: If fetching credentials or the token fails.
164167
ValueError: If the fetched token is invalid.
165168
"""
169+
166170
async def _token_getter() -> str:
167171
return await asyncio.to_thread(get_google_token_from_aud, audience)
168-
172+
169173
return _token_getter

0 commit comments

Comments
 (0)