Skip to content

Commit a799907

Browse files
authored
fixed mypy issues for acs identity sdk (#33965)
1 parent ad3cf0c commit a799907

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

sdk/communication/azure-communication-identity/samples/identity_samples.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232

3333
class CommunicationIdentityClientSamples(object):
3434
def __init__(self):
35-
self.connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING")
35+
self.connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING", "")
3636
self.client_id = os.getenv("AZURE_CLIENT_ID")
3737
self.client_secret = os.getenv("AZURE_CLIENT_SECRET")
3838
self.tenant_id = os.getenv("AZURE_TENANT_ID")
39-
self.m365_client_id = os.getenv("COMMUNICATION_M365_APP_ID")
39+
self.m365_client_id = os.getenv("COMMUNICATION_M365_APP_ID", "")
4040
self.m365_aad_authority = os.getenv("COMMUNICATION_M365_AAD_AUTHORITY")
4141
self.m365_aad_tenant = os.getenv("COMMUNICATION_M365_AAD_TENANT")
4242
self.msal_username = os.getenv("COMMUNICATION_MSAL_USERNAME")
@@ -64,11 +64,11 @@ def get_token(self):
6464
self.connection_string
6565
)
6666
user = identity_client.create_user()
67-
print("Getting token for: " + user.properties.get("id"))
67+
print(f"Getting token for: {user.properties.get('id')}")
6868
tokenresponse = identity_client.get_token(
6969
user, scopes=[CommunicationTokenScope.CHAT]
7070
)
71-
print("Token issued with value: " + tokenresponse.token)
71+
print(f"Token issued with value: {tokenresponse.token}")
7272

7373
def get_token_with_custom_expiration(self):
7474
from azure.communication.identity import (
@@ -92,14 +92,14 @@ def get_token_with_custom_expiration(self):
9292
self.connection_string
9393
)
9494
user = identity_client.create_user()
95-
print("Getting token for: " + user.properties.get("id"))
95+
print(f"Getting token for: {user.properties.get('id')}")
9696
token_expires_in = timedelta(hours=1)
9797
tokenresponse = identity_client.get_token(
9898
user,
9999
scopes=[CommunicationTokenScope.CHAT],
100100
token_expires_in=token_expires_in,
101101
)
102-
print("Issued token with custom expiration" + tokenresponse.token)
102+
print(f"Issued token with custom expiration {tokenresponse.token}")
103103

104104
def revoke_tokens(self):
105105
from azure.communication.identity import (
@@ -126,9 +126,9 @@ def revoke_tokens(self):
126126
tokenresponse = identity_client.get_token(
127127
user, scopes=[CommunicationTokenScope.CHAT]
128128
)
129-
print("Revoking token: " + tokenresponse.token)
129+
print(f"Revoking token: {tokenresponse.token}")
130130
identity_client.revoke_tokens(user)
131-
print(tokenresponse.token + " revoked successfully")
131+
print(f"{tokenresponse.token} revoked successfully")
132132

133133
def create_user(self):
134134
from azure.communication.identity import CommunicationIdentityClient
@@ -150,7 +150,7 @@ def create_user(self):
150150
)
151151
print("Creating new user")
152152
user = identity_client.create_user()
153-
print("User created with id:" + user.properties.get("id"))
153+
print(f"User created with id: {user.properties.get('id')}")
154154

155155
def create_user_and_token(self):
156156
from azure.communication.identity import (
@@ -177,8 +177,8 @@ def create_user_and_token(self):
177177
user, tokenresponse = identity_client.create_user_and_token(
178178
scopes=[CommunicationTokenScope.CHAT]
179179
)
180-
print("User created with id:" + user.properties.get("id"))
181-
print("Token issued with value: " + tokenresponse.token)
180+
print(f"User created with id: {user.properties.get('id')}")
181+
print(f"Token issued with value: {tokenresponse.token}")
182182

183183
def create_user_and_token_with_custom_expiration(self):
184184
from azure.communication.identity import (
@@ -206,8 +206,8 @@ def create_user_and_token_with_custom_expiration(self):
206206
user, tokenresponse = identity_client.create_user_and_token(
207207
scopes=[CommunicationTokenScope.CHAT], token_expires_in=token_expires_in
208208
)
209-
print("User created with id:" + user.properties.get("id"))
210-
print("Issued token with custom expiration: " + tokenresponse.token)
209+
print(f"User created with id: {user.properties.get('id')}")
210+
print(f"Issued token with custom expiration: {tokenresponse.token}")
211211

212212
def delete_user(self):
213213
from azure.communication.identity import CommunicationIdentityClient
@@ -228,9 +228,9 @@ def delete_user(self):
228228
self.connection_string
229229
)
230230
user = identity_client.create_user()
231-
print("Deleting user: " + user.properties.get("id"))
231+
print(f"Deleting user: {user.properties.get('id')}")
232232
identity_client.delete_user(user)
233-
print(user.properties.get("id") + " deleted")
233+
print(f"{user.properties.get('id')} deleted")
234234

235235
def get_token_for_teams_user(self):
236236
if os.getenv("SKIP_INT_IDENTITY_EXCHANGE_TOKEN_TEST") == "true":
@@ -267,12 +267,12 @@ def get_token_for_teams_user(self):
267267
)
268268
aad_token = result["access_token"]
269269
teams_user_oid = result["id_token_claims"]["oid"]
270-
print("AAD access token of a Teams User: " + aad_token)
270+
print(f"AAD access token of a Teams User: {aad_token}")
271271

272272
tokenresponse = identity_client.get_token_for_teams_user(
273273
aad_token, self.m365_client_id, teams_user_oid
274274
)
275-
print("Token issued with value: " + tokenresponse.token)
275+
print(f"Token issued with value: {tokenresponse.token}")
276276

277277

278278
if __name__ == "__main__":

sdk/communication/azure-communication-identity/samples/identity_samples_async.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434

3535
class CommunicationIdentityClientSamples(object):
3636
def __init__(self):
37-
self.connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING")
37+
self.connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING", "")
3838
self.endpoint = os.getenv("AZURE_COMMUNICATION_SERVICE_ENDPOINT")
3939
self.client_id = os.getenv("AZURE_CLIENT_ID")
4040
self.client_secret = os.getenv("AZURE_CLIENT_SECRET")
4141
self.tenant_id = os.getenv("AZURE_TENANT_ID")
42-
self.m365_client_id = os.getenv("COMMUNICATION_M365_APP_ID")
42+
self.m365_client_id = os.getenv("COMMUNICATION_M365_APP_ID", "")
4343
self.m365_aad_authority = os.getenv("COMMUNICATION_M365_AAD_AUTHORITY")
4444
self.m365_aad_tenant = os.getenv("COMMUNICATION_M365_AAD_TENANT")
4545
self.msal_username = os.getenv("COMMUNICATION_MSAL_USERNAME")
@@ -67,11 +67,11 @@ async def get_token(self):
6767

6868
async with identity_client:
6969
user = await identity_client.create_user()
70-
print("Issuing token for: " + user.properties.get("id"))
70+
print(f"Issuing token for: {user.properties.get('id')}")
7171
tokenresponse = await identity_client.get_token(
7272
user, scopes=[CommunicationTokenScope.CHAT]
7373
)
74-
print("Token issued with value: " + tokenresponse.token)
74+
print(f"Token issued with value: {tokenresponse.token}")
7575

7676
async def get_token_with_custom_expiration(self):
7777
from azure.communication.identity.aio import CommunicationIdentityClient
@@ -95,14 +95,14 @@ async def get_token_with_custom_expiration(self):
9595

9696
async with identity_client:
9797
user = await identity_client.create_user()
98-
print("Issuing token for: " + user.properties.get("id"))
98+
print(f"Issuing token for: {user.properties.get('id')}")
9999
token_expires_in = timedelta(hours=1)
100100
tokenresponse = await identity_client.get_token(
101101
user,
102102
scopes=[CommunicationTokenScope.CHAT],
103103
token_expires_in=token_expires_in,
104104
)
105-
print("Issued token with custom expiration: " + tokenresponse.token)
105+
print(f"Issued token with custom expiration: {tokenresponse.token}")
106106

107107
async def revoke_tokens(self):
108108
from azure.communication.identity.aio import CommunicationIdentityClient
@@ -129,9 +129,9 @@ async def revoke_tokens(self):
129129
tokenresponse = await identity_client.get_token(
130130
user, scopes=[CommunicationTokenScope.CHAT]
131131
)
132-
print("Revoking token: " + tokenresponse.token)
132+
print(f"Revoking token: {tokenresponse.token}")
133133
await identity_client.revoke_tokens(user)
134-
print(tokenresponse.token + " revoked successfully")
134+
print(f"{tokenresponse.token} revoked successfully")
135135

136136
async def create_user(self):
137137
from azure.communication.identity.aio import CommunicationIdentityClient
@@ -155,7 +155,7 @@ async def create_user(self):
155155
async with identity_client:
156156
print("Creating new user")
157157
user = await identity_client.create_user()
158-
print("User created with id:" + user.properties.get("id"))
158+
print(f"User created with id: {user.properties.get('id')}")
159159

160160
async def create_user_and_token(self):
161161
from azure.communication.identity.aio import CommunicationIdentityClient
@@ -182,8 +182,8 @@ async def create_user_and_token(self):
182182
user, tokenresponse = await identity_client.create_user_and_token(
183183
scopes=[CommunicationTokenScope.CHAT]
184184
)
185-
print("User created with id:" + user.properties.get("id"))
186-
print("Token issued with value: " + tokenresponse.token)
185+
print(f"User created with id: {user.properties.get('id')}")
186+
print(f"Token issued with value: {tokenresponse.token}")
187187

188188
async def create_user_and_token_with_custom_expiration(self):
189189
from azure.communication.identity.aio import CommunicationIdentityClient
@@ -211,8 +211,8 @@ async def create_user_and_token_with_custom_expiration(self):
211211
user, tokenresponse = await identity_client.create_user_and_token(
212212
scopes=[CommunicationTokenScope.CHAT], token_expires_in=token_expires_in
213213
)
214-
print("User created with id:" + user.properties.get("id"))
215-
print("Issued token with custom expiration: " + tokenresponse.token)
214+
print(f"User created with id: {user.properties.get('id')}")
215+
print(f"Issued token with custom expiration: {tokenresponse.token}")
216216

217217
async def delete_user(self):
218218
from azure.communication.identity.aio import CommunicationIdentityClient
@@ -235,9 +235,9 @@ async def delete_user(self):
235235

236236
async with identity_client:
237237
user = await identity_client.create_user()
238-
print("Deleting user: " + user.properties.get("id"))
238+
print(f"Deleting user: {user.properties.get('id')}")
239239
await identity_client.delete_user(user)
240-
print(user.properties.get("id") + " deleted")
240+
print(f"{user.properties.get('id')} deleted")
241241

242242
async def get_token_for_teams_user(self):
243243
if os.getenv("SKIP_INT_IDENTITY_EXCHANGE_TOKEN_TEST") == "true":
@@ -275,12 +275,12 @@ async def get_token_for_teams_user(self):
275275
)
276276
aad_token = result["access_token"]
277277
teams_user_oid = result["id_token_claims"]["oid"]
278-
print("AAD access token of a Teams User: " + aad_token)
278+
print(f"AAD access token of a Teams User: {aad_token}")
279279

280280
tokenresponse = await identity_client.get_token_for_teams_user(
281281
aad_token, self.m365_client_id, teams_user_oid
282282
)
283-
print("Token issued with value: " + tokenresponse.token)
283+
print(f"Token issued with value: {tokenresponse.token}")
284284

285285

286286
async def main():

0 commit comments

Comments
 (0)