@@ -106,11 +106,17 @@ async def get_token(
106106 receive an access token.
107107 """
108108 if claims and claims .strip ():
109- raise CredentialUnavailableError (f"Fail to get token, please run az login --claims-challenge { claims } " )
109+ raise CredentialUnavailableError (
110+ f"Fail to get token, please run az login --claims-challenge { claims } "
111+ )
110112
111113 # only ProactorEventLoop supports subprocesses on Windows (and it isn't the default loop on Python < 3.8)
112- if sys .platform .startswith ("win" ) and not isinstance (asyncio .get_event_loop (), asyncio .ProactorEventLoop ):
113- return _SyncAzureCliCredential ().get_token (* scopes , tenant_id = tenant_id , ** kwargs )
114+ if sys .platform .startswith ("win" ) and not isinstance (
115+ asyncio .get_event_loop (), asyncio .ProactorEventLoop
116+ ):
117+ return _SyncAzureCliCredential ().get_token (
118+ * scopes , tenant_id = tenant_id , ** kwargs
119+ )
114120
115121 options : TokenRequestOptions = {}
116122 if tenant_id :
@@ -120,7 +126,9 @@ async def get_token(
120126 return AccessToken (token_info .token , token_info .expires_on )
121127
122128 @log_get_token_async
123- async def get_token_info (self , * scopes : str , options : Optional [TokenRequestOptions ] = None ) -> AccessTokenInfo :
129+ async def get_token_info (
130+ self , * scopes : str , options : Optional [TokenRequestOptions ] = None
131+ ) -> AccessTokenInfo :
124132 """Request an access token for `scopes`.
125133
126134 This is an alternative to `get_token` to enable certain scenarios that require additional properties
@@ -146,7 +154,9 @@ async def get_token_info(self, *scopes: str, options: Optional[TokenRequestOptio
146154 f"Fail to get token, please run az login --claims-challenge { claims_value } "
147155 )
148156 # only ProactorEventLoop supports subprocesses on Windows (and it isn't the default loop on Python < 3.8)
149- if sys .platform .startswith ("win" ) and not isinstance (asyncio .get_event_loop (), asyncio .ProactorEventLoop ):
157+ if sys .platform .startswith ("win" ) and not isinstance (
158+ asyncio .get_event_loop (), asyncio .ProactorEventLoop
159+ ):
150160 return _SyncAzureCliCredential ().get_token_info (* scopes , options = options )
151161 return await self ._get_token_base (* scopes , options = options )
152162
@@ -197,7 +207,9 @@ async def _run_command(command_args: List[str], timeout: int) -> str:
197207 # Ensure executable exists in PATH first. This avoids a subprocess call that would fail anyway.
198208 if sys .platform .startswith ("win" ):
199209 # On Windows, the expected executable is az.cmd, so we check for that first, falling back to 'az' in case.
200- az_path = shutil .which (EXECUTABLE_NAME + ".cmd" ) or shutil .which (EXECUTABLE_NAME )
210+ az_path = shutil .which (EXECUTABLE_NAME + ".cmd" ) or shutil .which (
211+ EXECUTABLE_NAME
212+ )
201213 else :
202214 az_path = shutil .which (EXECUTABLE_NAME )
203215 if not az_path :
@@ -220,10 +232,14 @@ async def _run_command(command_args: List[str], timeout: int) -> str:
220232 stderr = stderr_b .decode ()
221233 except asyncio .TimeoutError as ex :
222234 proc .kill ()
223- raise CredentialUnavailableError (message = "Timed out waiting for Azure CLI" ) from ex
235+ raise CredentialUnavailableError (
236+ message = "Timed out waiting for Azure CLI"
237+ ) from ex
224238 except OSError as ex :
225239 # failed to execute 'cmd' or '/bin/sh'
226- error = CredentialUnavailableError (message = "Failed to execute '{}'" .format (args [0 ]))
240+ error = CredentialUnavailableError (
241+ message = "Failed to execute '{}'" .format (args [0 ])
242+ )
227243 raise error from ex
228244
229245 if proc .returncode == 0 :
0 commit comments