Skip to content

Commit eb3eb89

Browse files
Copilotxiangyan99
andcommitted
Fix MyPy errors in AzureCliCredential claims challenge handling
Co-authored-by: xiangyan99 <[email protected]>
1 parent 37b031e commit eb3eb89

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

sdk/identity/azure-identity/azure/identity/_credentials/azure_cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ def get_token_info(self, *scopes: str, options: Optional[TokenRequestOptions] =
144144
:raises ~azure.core.exceptions.ClientAuthenticationError: the credential invoked the Azure CLI but didn't
145145
receive an access token.
146146
"""
147-
if options and options.get("claims") and options.get("claims").strip():
148-
claims = options["claims"]
149-
raise CredentialUnavailableError(f"Fail to get token, please run az login --claims-challenge {claims}")
147+
claims_value = options.get("claims") if options else None
148+
if claims_value and claims_value.strip():
149+
raise CredentialUnavailableError(f"Fail to get token, please run az login --claims-challenge {claims_value}")
150150

151151
return self._get_token_base(*scopes, options=options)
152152

sdk/identity/azure-identity/azure/identity/aio/_credentials/azure_cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ async def get_token_info(self, *scopes: str, options: Optional[TokenRequestOptio
139139
:raises ~azure.core.exceptions.ClientAuthenticationError: the credential invoked the Azure CLI but didn't
140140
receive an access token.
141141
"""
142-
if options and options.get("claims") and options.get("claims").strip():
143-
claims = options["claims"]
144-
raise CredentialUnavailableError(f"Fail to get token, please run az login --claims-challenge {claims}")
142+
claims_value = options.get("claims") if options else None
143+
if claims_value and claims_value.strip():
144+
raise CredentialUnavailableError(f"Fail to get token, please run az login --claims-challenge {claims_value}")
145145

146146
# only ProactorEventLoop supports subprocesses on Windows (and it isn't the default loop on Python < 3.8)
147147
if sys.platform.startswith("win") and not isinstance(asyncio.get_event_loop(), asyncio.ProactorEventLoop):

0 commit comments

Comments
 (0)