44import contextvars
55import logging
66import os
7+ from collections .abc import Callable
78from functools import wraps
8- from typing import Any , Callable , Dict , List , Literal , Optional
9+ from typing import Any , Literal
910
1011import boto3
1112
@@ -22,14 +23,14 @@ def requires_access_token(
2223 * ,
2324 provider_name : str ,
2425 into : str = "access_token" ,
25- scopes : List [str ],
26- on_auth_url : Optional [ Callable [[str ], Any ]] = None ,
26+ scopes : list [str ],
27+ on_auth_url : Callable [[str ], Any ] | None = None ,
2728 auth_flow : Literal ["M2M" , "USER_FEDERATION" ],
28- callback_url : Optional [ str ] = None ,
29+ callback_url : str | None = None ,
2930 force_authentication : bool = False ,
30- token_poller : Optional [ TokenPoller ] = None ,
31- custom_state : Optional [ str ] = None ,
32- custom_parameters : Optional [ Dict [ str , str ]] = None ,
31+ token_poller : TokenPoller | None = None ,
32+ custom_state : str | None = None ,
33+ custom_parameters : dict [ str , str ] | None = None ,
3334) -> Callable :
3435 """Decorator that fetches an OAuth2 access token before calling the decorated function.
3536
@@ -151,7 +152,7 @@ def sync_wrapper(*args: Any, **kwargs: Any) -> Any:
151152 return decorator
152153
153154
154- def _get_oauth2_callback_url (user_provided_oauth2_callback_url : Optional [ str ] ):
155+ def _get_oauth2_callback_url (user_provided_oauth2_callback_url : str | None ):
155156 if user_provided_oauth2_callback_url :
156157 return user_provided_oauth2_callback_url
157158
@@ -184,7 +185,7 @@ async def _set_up_local_auth(client: IdentityClient) -> str:
184185 config = {}
185186 if config_path .exists ():
186187 try :
187- with open (config_path , "r" , encoding = "utf-8" ) as file :
188+ with open (config_path , encoding = "utf-8" ) as file :
188189 config = json .load (file ) or {}
189190 except Exception :
190191 print ("Could not find existing workload identity and user id" )
0 commit comments