Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def serialize_identifier(identifier):
:rtype: ~azure.communication.chat._generated.models.CommunicationIdentifierModel
"""
try:
request_model = {"raw_id": identifier.raw_id}
request_model: Dict[str, Any] = {"raw_id": identifier.raw_id}

if identifier.kind and identifier.kind != CommunicationIdentifierKind.UNKNOWN:
request_model[identifier.kind] = dict(identifier.properties)
Expand All @@ -52,7 +52,7 @@ def deserialize_identifier(identifier_model):
raw_id = identifier_model.raw_id

if identifier_model.communication_user:
return CommunicationUserIdentifier(raw_id, raw_id=raw_id)
return CommunicationUserIdentifier(raw_id or "", raw_id=raw_id)
if identifier_model.phone_number:
return PhoneNumberIdentifier(identifier_model.phone_number.value, raw_id=raw_id)
if identifier_model.microsoft_teams_user:
Expand All @@ -62,4 +62,4 @@ def deserialize_identifier(identifier_model):
is_anonymous=identifier_model.microsoft_teams_user.is_anonymous,
cloud=identifier_model.microsoft_teams_user.cloud,
)
return UnknownIdentifier(raw_id)
return UnknownIdentifier(raw_id or "")
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
# license information.
# --------------------------------------------------------------------------

from typing import List, Tuple, Dict, Optional, TYPE_CHECKING

if TYPE_CHECKING:
from ._models import ChatParticipant
from ._generated.models import ChatError


def _to_utc_datetime(value):
return value.strftime("%Y-%m-%dT%H:%M:%SZ")
Expand All @@ -24,7 +30,7 @@ class CommunicationErrorResponseConverter(object):

@classmethod
def convert(cls, participants, chat_errors):
# type: (...) -> list[(ChatThreadParticipant, ChatError)]
# type: (List[ChatParticipant], Optional[List[ChatError]]) -> List[Tuple[Optional[ChatParticipant], ChatError]]
"""
Util function to convert AddChatParticipantsResult.

Expand All @@ -41,12 +47,12 @@ def convert(cls, participants, chat_errors):
"""

def create_dict(participants):
# type: (...) -> Dict(str, ChatThreadParticipant)
# type: (List[ChatParticipant]) -> Dict[str, ChatParticipant]
"""
Create dictionary of id -> ChatParticipant

:param list participants: list of ChatThreadParticipant
:return: Dictionary of id -> ChatThreadParticipant
:param list participants: list of ChatParticipant
:return: Dictionary of id -> ChatParticipant
:rtype: dict
"""
result = {}
Expand All @@ -56,11 +62,13 @@ def create_dict(participants):

_thread_participants_dict = create_dict(participants=participants)

failed_chat_thread_participants = []
failed_chat_thread_participants: List[Tuple[Optional["ChatParticipant"], "ChatError"]] = []

if chat_errors is not None:
for chat_error in chat_errors:
_thread_participant = _thread_participants_dict.get(chat_error.target)
failed_chat_thread_participants.append((_thread_participant, chat_error))
target = chat_error.target
if target is not None:
_thread_participant = _thread_participants_dict.get(target)
failed_chat_thread_participants.append((_thread_participant, chat_error))

return failed_chat_thread_participants
2 changes: 1 addition & 1 deletion sdk/communication/azure-communication-chat/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[tool.azure-sdk-build]
mypy = false
mypy = true
pyright = false
type_check_samples = false