Skip to content

Commit 19583da

Browse files
committed
pylint
1 parent 43401e7 commit 19583da

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/azure-cli-core/azure/cli/core/_profile.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ def login_with_managed_identity(self, identity_id=None, allow_no_subscriptions=N
206206
else:
207207
authenticated = False
208208
# Use trial and error approach to determine the ID type - client ID or object ID
209-
from azure.cli.core.azclierror import AuthenticationError
210209
try:
211210
cred = ManagedIdentityCredential(client_id=identity_id)
212211
cred.get_token(*self._arm_scope)
@@ -714,7 +713,7 @@ def get_installation_id(self):
714713
return installation_id
715714

716715

717-
class ManagedIdentityAuth:
716+
class ManagedIdentityAuth: # pylint: disable=too-few-public-methods
718717

719718
# String constants defined in this class are saved to azureProfile.json, so this class shouldn't be put
720719
# under auth/identity.py

src/azure-cli-core/azure/cli/core/auth/msal_authentication.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,25 +157,24 @@ def get_token(self, *scopes, **kwargs):
157157
return build_sdk_access_token(result)
158158

159159

160-
class CloudShellCredential:
160+
class CloudShellCredential: # pylint: disable=too-few-public-methods
161161

162-
def get_token(self, *scopes, **kwargs):
163-
logger.debug("CloudShellCredential.get_token: scopes=%r, kwargs=%r", scopes, kwargs)
164-
165-
import msal
166-
from .util import check_result, build_sdk_access_token
162+
def __init__(self):
167163
from .identity import AZURE_CLI_CLIENT_ID
168-
app = msal.PublicClientApplication(
164+
self.msal_app = PublicClientApplication(
169165
AZURE_CLI_CLIENT_ID, # Use a real client_id, so that cache would work
170166
# TODO: This PoC does not currently maintain a token cache;
171167
# Ideally we should reuse the real MSAL app object which has cache configured.
172168
# token_cache=...,
173169
)
170+
171+
def get_token(self, *scopes, **kwargs): # pylint: disable=no-self-use
172+
logger.debug("CloudShellCredential.get_token: scopes=%r, kwargs=%r", scopes, kwargs)
174173
if 'data' in kwargs:
175174
# Get a VM SSH certificate
176-
result = app.acquire_token_interactive(list(scopes), prompt="none", data=kwargs["data"])
175+
result = self.msal_app.acquire_token_interactive(list(scopes), prompt="none", data=kwargs["data"])
177176
else:
178177
# Get an access token
179-
result = app.acquire_token_interactive(list(scopes), prompt="none")
178+
result = self.msal_app.acquire_token_interactive(list(scopes), prompt="none")
180179
check_result(result, scopes=scopes)
181180
return build_sdk_access_token(result)

0 commit comments

Comments
 (0)