Skip to content

Commit 2bebcff

Browse files
Juntuchen/update black (Azure#38542)
* updated OPSoutgoingCall and Callinvite * updated according to pipeline build * revert change in ci.yml * Fixed pylint issue * updated to fix black * Ran black in all comm services * Ran black for all comm services * updated chat to meet pipeline check
1 parent 5a6324c commit 2bebcff

File tree

237 files changed

+4246
-5863
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+4246
-5863
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
from ._version import VERSION
22
from ._chat_client import ChatClient
33
from ._chat_thread_client import ChatThreadClient
4-
from ._generated.models import (
5-
ChatAttachmentType,
6-
SendChatMessageResult,
7-
ChatThreadItem,
8-
ChatMessageType,
9-
ChatError
10-
)
4+
from ._generated.models import ChatAttachmentType, SendChatMessageResult, ChatThreadItem, ChatMessageType, ChatError
115

126
from ._models import (
137
ChatAttachment,
@@ -16,7 +10,7 @@
1610
ChatThreadProperties,
1711
ChatMessageReadReceipt,
1812
ChatMessageContent,
19-
CreateChatThreadResult
13+
CreateChatThreadResult,
2014
)
2115

2216
from ._shared.user_credential import CommunicationTokenCredential
@@ -32,36 +26,36 @@
3226
MicrosoftTeamsAppProperties,
3327
MicrosoftTeamsUserIdentifier,
3428
MicrosoftTeamsUserProperties,
35-
UnknownIdentifier
29+
UnknownIdentifier,
3630
)
3731

3832
__all__ = [
39-
'ChatClient',
40-
'ChatThreadClient',
41-
'ChatMessage',
42-
'ChatMessageContent',
43-
'ChatMessageReadReceipt',
44-
'SendChatMessageResult',
45-
'ChatThreadProperties',
46-
'ChatThreadItem',
47-
'ChatParticipant',
48-
'ChatMessageType',
49-
'ChatAttachment',
50-
'ChatAttachmentType',
51-
'CreateChatThreadResult',
52-
'ChatError',
53-
'CommunicationTokenCredential',
54-
'CommunicationIdentifier',
55-
'CommunicationIdentifierKind',
56-
'CommunicationUserIdentifier',
57-
'CommunicationUserProperties',
58-
'MicrosoftTeamsAppIdentifier',
59-
'MicrosoftTeamsAppProperties',
60-
'MicrosoftTeamsUserIdentifier',
61-
'MicrosoftTeamsUserProperties',
62-
'identifier_from_raw_id',
63-
'PhoneNumberIdentifier',
64-
'PhoneNumberProperties',
65-
'UnknownIdentifier'
33+
"ChatClient",
34+
"ChatThreadClient",
35+
"ChatMessage",
36+
"ChatMessageContent",
37+
"ChatMessageReadReceipt",
38+
"SendChatMessageResult",
39+
"ChatThreadProperties",
40+
"ChatThreadItem",
41+
"ChatParticipant",
42+
"ChatMessageType",
43+
"ChatAttachment",
44+
"ChatAttachmentType",
45+
"CreateChatThreadResult",
46+
"ChatError",
47+
"CommunicationTokenCredential",
48+
"CommunicationIdentifier",
49+
"CommunicationIdentifierKind",
50+
"CommunicationUserIdentifier",
51+
"CommunicationUserProperties",
52+
"MicrosoftTeamsAppIdentifier",
53+
"MicrosoftTeamsAppProperties",
54+
"MicrosoftTeamsUserIdentifier",
55+
"MicrosoftTeamsUserProperties",
56+
"identifier_from_raw_id",
57+
"PhoneNumberIdentifier",
58+
"PhoneNumberProperties",
59+
"UnknownIdentifier",
6660
]
6761
__version__ = VERSION

sdk/communication/azure-communication-chat/azure/communication/chat/_chat_client.py

Lines changed: 28 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@
1414
from ._shared.user_credential import CommunicationTokenCredential
1515
from ._generated import AzureCommunicationChatService
1616
from ._generated.models import CreateChatThreadRequest
17-
from ._models import (
18-
ChatThreadProperties,
19-
CreateChatThreadResult
20-
)
21-
from ._utils import ( # pylint: disable=unused-import
17+
from ._models import ChatThreadProperties, CreateChatThreadResult
18+
from ._utils import ( # pylint: disable=unused-import
2219
_to_utc_datetime,
2320
return_response,
24-
CommunicationErrorResponseConverter
21+
CommunicationErrorResponseConverter,
2522
)
2623
from ._version import SDK_MONIKER
2724

@@ -31,7 +28,7 @@
3128
from azure.core.paging import ItemPaged
3229

3330

34-
class ChatClient(object): # pylint: disable=client-accepts-api-version-keyword
31+
class ChatClient(object): # pylint: disable=client-accepts-api-version-keyword
3532
"""A client to interact with the AzureCommunicationService Chat gateway.
3633
3734
This client provides operations to create chat thread, delete chat thread,
@@ -53,22 +50,22 @@ class ChatClient(object): # pylint: disable=client-accepts-api-version-keyword
5350
"""
5451

5552
def __init__(
56-
self,
57-
endpoint, # type: str
58-
credential, # type: CommunicationTokenCredential
59-
**kwargs # type: Any
53+
self,
54+
endpoint, # type: str
55+
credential, # type: CommunicationTokenCredential
56+
**kwargs # type: Any
6057
):
6158
# type: (...) -> None
6259
if not credential:
6360
raise ValueError("credential can not be None")
6461

6562
try:
66-
if not endpoint.lower().startswith('http'):
63+
if not endpoint.lower().startswith("http"):
6764
endpoint = "https://" + endpoint
6865
except AttributeError:
69-
raise ValueError("Host URL must be a string") # pylint:disable=raise-missing-from
66+
raise ValueError("Host URL must be a string") # pylint:disable=raise-missing-from
7067

71-
parsed_url = urlparse(endpoint.rstrip('/'))
68+
parsed_url = urlparse(endpoint.rstrip("/"))
7269
if not parsed_url.netloc:
7370
raise ValueError("Invalid URL: {}".format(endpoint))
7471

@@ -84,7 +81,8 @@ def __init__(
8481

8582
@distributed_trace
8683
def get_chat_thread_client(
87-
self, thread_id, # type: str
84+
self,
85+
thread_id, # type: str
8886
**kwargs # type: Any
8987
):
9088
# type: (...) -> ChatThreadClient
@@ -109,16 +107,12 @@ def get_chat_thread_client(
109107
if not thread_id:
110108
raise ValueError("thread_id cannot be None.")
111109

112-
return ChatThreadClient(
113-
endpoint=self._endpoint,
114-
credential=self._credential,
115-
thread_id=thread_id,
116-
**kwargs
117-
)
110+
return ChatThreadClient(endpoint=self._endpoint, credential=self._credential, thread_id=thread_id, **kwargs)
118111

119112
@distributed_trace
120113
def create_chat_thread(
121-
self, topic, # type: str
114+
self,
115+
topic, # type: str
122116
**kwargs # type: Any
123117
):
124118
# type: (...) -> CreateChatThreadResult
@@ -151,45 +145,37 @@ def create_chat_thread(
151145
if not topic:
152146
raise ValueError("topic cannot be None.")
153147

154-
idempotency_token = kwargs.pop('idempotency_token', None)
148+
idempotency_token = kwargs.pop("idempotency_token", None)
155149
if idempotency_token is None:
156150
idempotency_token = str(uuid4())
157151

158-
thread_participants = kwargs.pop('thread_participants', None)
152+
thread_participants = kwargs.pop("thread_participants", None)
159153
participants = []
160154
if thread_participants is not None:
161155
participants = [m._to_generated() for m in thread_participants] # pylint:disable=protected-access
162156

163157
create_thread_request = CreateChatThreadRequest(topic=topic, participants=participants)
164158

165159
create_chat_thread_result = self._client.chat.create_chat_thread(
166-
create_chat_thread_request=create_thread_request,
167-
repeatability_request_id=idempotency_token,
168-
**kwargs)
160+
create_chat_thread_request=create_thread_request, repeatability_request_id=idempotency_token, **kwargs
161+
)
169162

170163
errors = None
171-
if hasattr(create_chat_thread_result, 'invalid_participants'):
164+
if hasattr(create_chat_thread_result, "invalid_participants"):
172165
errors = CommunicationErrorResponseConverter.convert(
173-
participants=thread_participants or [],
174-
chat_errors=create_chat_thread_result.invalid_participants
166+
participants=thread_participants or [], chat_errors=create_chat_thread_result.invalid_participants
175167
)
176168

177-
chat_thread_properties = ChatThreadProperties._from_generated( # pylint:disable=protected-access
178-
create_chat_thread_result.chat_thread)
179-
180-
create_chat_thread_result = CreateChatThreadResult(
181-
chat_thread=chat_thread_properties,
182-
errors=errors
169+
chat_thread_properties = ChatThreadProperties._from_generated( # pylint:disable=protected-access
170+
create_chat_thread_result.chat_thread
183171
)
184172

185-
return create_chat_thread_result
173+
create_chat_thread_result = CreateChatThreadResult(chat_thread=chat_thread_properties, errors=errors)
186174

175+
return create_chat_thread_result
187176

188177
@distributed_trace
189-
def list_chat_threads(
190-
self,
191-
**kwargs
192-
):
178+
def list_chat_threads(self, **kwargs):
193179
# type: (...) -> ItemPaged[ChatThreadItem]
194180
"""Gets the list of chat threads of a user.
195181
@@ -211,10 +197,7 @@ def list_chat_threads(
211197
results_per_page = kwargs.pop("results_per_page", None)
212198
start_time = kwargs.pop("start_time", None)
213199

214-
return self._client.chat.list_chat_threads(
215-
max_page_size=results_per_page,
216-
start_time=start_time,
217-
**kwargs)
200+
return self._client.chat.list_chat_threads(max_page_size=results_per_page, start_time=start_time, **kwargs)
218201

219202
@distributed_trace
220203
def delete_chat_thread(

0 commit comments

Comments
 (0)