Skip to content

Commit 0f5058b

Browse files
authored
[Identity] Update for next-pylint (#42994)
Signed-off-by: Paul Van Eck <[email protected]>
1 parent dadd0f4 commit 0f5058b

File tree

5 files changed

+16
-22
lines changed

5 files changed

+16
-22
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,11 @@ def __init__(self, **kwargs: Any) -> None: # pylint: disable=too-many-statement
278278
)
279279
)
280280
if not exclude_shared_token_cache_credential and SharedTokenCacheCredential.supported():
281-
try:
282-
# username and/or tenant_id are only required when the cache contains tokens for multiple identities
283-
shared_cache = SharedTokenCacheCredential(
284-
username=shared_cache_username, tenant_id=shared_cache_tenant_id, authority=authority, **kwargs
285-
)
286-
credentials.append(shared_cache)
287-
except Exception as ex: # pylint:disable=broad-except
288-
_LOGGER.info("Shared token cache is unavailable: '%s'", ex)
281+
# username and/or tenant_id are only required when the cache contains tokens for multiple identities
282+
shared_cache = SharedTokenCacheCredential(
283+
username=shared_cache_username, tenant_id=shared_cache_tenant_id, authority=authority, **kwargs
284+
)
285+
credentials.append(shared_cache)
289286
if not exclude_visual_studio_code_credential:
290287
credentials.append(VisualStudioCodeCredential(tenant_id=vscode_tenant_id))
291288
if not exclude_cli_credential:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ def _get_token_base(
198198
return token
199199
except Exception as e: # pylint: disable=broad-except
200200
if within_dac.get():
201-
raise CredentialUnavailableError( # pylint: disable=raise-missing-from
201+
raise CredentialUnavailableError(
202202
message=getattr(e, "message", str(e)), response=getattr(e, "response", None)
203-
)
203+
) from e
204204
raise
205205

206206
raise CredentialUnavailableError(message=NO_TOKEN.format(account.get("username")))

sdk/identity/azure-identity/azure/identity/_internal/interactive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def _get_token_base(
203203
return token
204204
except Exception as ex: # pylint:disable=broad-except
205205
if not (isinstance(ex, AuthenticationRequiredError) and allow_prompt):
206-
_LOGGER.warning(
206+
_LOGGER.warning( # pylint: disable=do-not-log-raised-errors
207207
"%s.%s failed: %s",
208208
self.__class__.__name__,
209209
base_method_name,
@@ -225,7 +225,7 @@ def _get_token_base(
225225
# this may be the first authentication, or the user may have authenticated a different identity
226226
self._auth_record = _build_auth_record(result)
227227
except Exception as ex:
228-
_LOGGER.warning(
228+
_LOGGER.warning( # pylint: disable=do-not-log-raised-errors
229229
"%s.%s failed: %s",
230230
self.__class__.__name__,
231231
base_method_name,

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,11 @@ def __init__(self, **kwargs: Any) -> None: # pylint: disable=too-many-statement
239239
)
240240
)
241241
if not exclude_shared_token_cache_credential and SharedTokenCacheCredential.supported():
242-
try:
243-
# username and/or tenant_id are only required when the cache contains tokens for multiple identities
244-
shared_cache = SharedTokenCacheCredential(
245-
username=shared_cache_username, tenant_id=shared_cache_tenant_id, authority=authority, **kwargs
246-
)
247-
credentials.append(shared_cache)
248-
except Exception as ex: # pylint:disable=broad-except
249-
_LOGGER.info("Shared token cache is unavailable: '%s'", ex)
242+
# username and/or tenant_id are only required when the cache contains tokens for multiple identities
243+
shared_cache = SharedTokenCacheCredential(
244+
username=shared_cache_username, tenant_id=shared_cache_tenant_id, authority=authority, **kwargs
245+
)
246+
credentials.append(shared_cache)
250247
if not exclude_visual_studio_code_credential:
251248
credentials.append(VisualStudioCodeCredential(tenant_id=vscode_tenant_id))
252249
if not exclude_cli_credential:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ async def _get_token_base(
151151
return token
152152
except Exception as e: # pylint: disable=broad-except
153153
if within_dac.get():
154-
raise CredentialUnavailableError( # pylint: disable=raise-missing-from
154+
raise CredentialUnavailableError(
155155
message=getattr(e, "message", str(e)), response=getattr(e, "response", None)
156-
)
156+
) from e
157157
raise
158158
raise CredentialUnavailableError(message=NO_TOKEN.format(account.get("username")))
159159

0 commit comments

Comments
 (0)