From da973714df286ab9eaff30df215cc8d2e6d2acbf Mon Sep 17 00:00:00 2001 From: Rajarshi Sarkar <73562869+sarkar-rajarshi@users.noreply.github.com> Date: Thu, 4 Feb 2021 18:52:24 -0800 Subject: [PATCH 1/2] apiview fixes - Add missing type hints - return ItemPaged or AsyncItemPaged instead of full classpath --- .../azure/communication/chat/_chat_client.py | 2 +- .../communication/chat/_chat_thread_client.py | 6 +++--- .../azure/communication/chat/_models.py | 18 +++++++++++++----- .../chat/aio/_chat_client_async.py | 8 ++++---- .../chat/aio/_chat_thread_client_async.py | 14 +++++++------- 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_client.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_client.py index d2041fdf6499..5b685d03381b 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_client.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_client.py @@ -224,7 +224,7 @@ def list_chat_threads( :keyword ~datetime.datetime start_time: The earliest point in time to get chat threads up to. :keyword callable cls: A custom type or function that will be passed the direct response :return: ItemPaged[:class:`~azure.communication.chat.ChatThreadInfo`] - :rtype: ~azure.core.paging.ItemPaged + :rtype: ItemPaged :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py index 6e39b0b176db..49b7ca5ca604 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py @@ -192,7 +192,7 @@ def list_read_receipts( :keyword int skip: Skips chat message read receipts up to a specified position in response. :keyword callable cls: A custom type or function that will be passed the direct response :return: ItemPaged[:class:`~azure.communication.chat.ChatMessageReadReceipt`] - :rtype: ~azure.core.paging.ItemPaged + :rtype: ItemPaged :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: @@ -342,7 +342,7 @@ def list_messages( :keyword ~datetime.datetime start_time: The start time where the range query. :keyword callable cls: A custom type or function that will be passed the direct response :return: ItemPaged[:class:`~azure.communication.chat.ChatMessage`] - :rtype: ~azure.core.paging.ItemPaged + :rtype: ItemPaged :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: @@ -449,7 +449,7 @@ def list_participants( :keyword int skip: Skips participants up to a specified position in response. :keyword callable cls: A custom type or function that will be passed the direct response :return: ItemPaged[:class:`~azure.communication.chat.ChatThreadParticipant`] - :rtype: ~azure.core.paging.ItemPaged + :rtype: ItemPaged :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_models.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_models.py index 30ca4fe3a95e..5055b1c40369 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_models.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_models.py @@ -24,8 +24,10 @@ class ChatThreadParticipant(object): def __init__( self, - **kwargs + **kwargs # type: Any ): + # type: (...) -> None + self.user = kwargs['user'] self.display_name = kwargs.get('display_name', None) self.share_history_time = kwargs.get('share_history_time', None) @@ -80,8 +82,10 @@ class ChatMessage(object): def __init__( self, - **kwargs + **kwargs # type: Any ): + # type: (...) -> None + self.id = kwargs['id'] self.type = kwargs['type'] self.sequence_id = kwargs['sequence_id'] @@ -134,8 +138,10 @@ class ChatMessageContent(object): def __init__( self, - **kwargs + **kwargs # type: Any ): + # type: (...) -> None + self.message = kwargs.get('message', None) self.topic = kwargs.get('topic', None) self.participants = kwargs.get('participants', None) @@ -178,8 +184,9 @@ class ChatThread(object): def __init__( self, - **kwargs + **kwargs # type: Any ): + # type: (...) -> None self.id = kwargs['id'] self.topic = kwargs.get('topic', None) self.created_on = kwargs['created_on'] @@ -213,8 +220,9 @@ class ChatMessageReadReceipt(object): def __init__( self, - **kwargs + **kwargs # type: Any ): + # type: (...) -> None self.sender = kwargs['sender'] self.chat_message_id = kwargs['chat_message_id'] self.read_on = kwargs['read_on'] diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_client_async.py b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_client_async.py index dfb29899c234..ae28ce325d0b 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_client_async.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_client_async.py @@ -59,7 +59,7 @@ class ChatClient(object): def __init__( self, endpoint: str, credential: CommunicationTokenCredential, - **kwargs + **kwargs: Any ) -> None: if not credential: raise ValueError("credential can not be None") @@ -86,7 +86,7 @@ def __init__( @distributed_trace def get_chat_thread_client( self, thread_id: str, - **kwargs + **kwargs: Any ) -> ChatThreadClient: """ Get ChatThreadClient by providing a thread_id. @@ -213,7 +213,7 @@ async def get_chat_thread( @distributed_trace def list_chat_threads( self, - **kwargs + **kwargs: Any ) -> AsyncItemPaged[ChatThreadInfo]: """Gets the list of chat threads of a user. @@ -221,7 +221,7 @@ def list_chat_threads( :keyword ~datetime.datetime start_time: The earliest point in time to get chat threads up to. :keyword callable cls: A custom type or function that will be passed the direct response :return: AsyncItemPaged[:class:`~azure.communication.chat.ChatThreadInfo`] - :rtype: ~azure.core.async_paging.AsyncItemPaged + :rtype: AsyncItemPaged :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py index 8a042712b7bc..09f013752a48 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py @@ -73,7 +73,7 @@ def __init__( endpoint: str, credential: CommunicationTokenCredential, thread_id: str, - **kwargs + **kwargs: Any ) -> None: if not thread_id: raise ValueError("thread_id can not be None or empty") @@ -180,14 +180,14 @@ async def send_read_receipt( @distributed_trace def list_read_receipts( self, - **kwargs + **kwargs: Any ) -> AsyncItemPaged[ChatMessageReadReceipt]: """Gets read receipts for a thread. :keyword int results_per_page: The maximum number of chat message read receipts to be returned per page. :keyword int skip: Skips chat message read receipts up to a specified position in response. :return: AsyncItemPaged[:class:`~azure.communication.chat.ChatMessageReadReceipt`] - :rtype: ~azure.core.async_paging.AsyncItemPaged + :rtype: AsyncItemPaged :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: @@ -325,7 +325,7 @@ async def get_message( @distributed_trace def list_messages( self, - **kwargs + **kwargs: Any ) -> AsyncItemPaged[ChatMessage]: """Gets a list of messages from a thread. @@ -333,7 +333,7 @@ def list_messages( :keyword ~datetime.datetime start_time: The start time where the range query. :keyword callable cls: A custom type or function that will be passed the direct response :return: AsyncItemPaged[:class:`~azure.communication.chat.ChatMessage`] - :rtype: ~azure.core.async_paging.AsyncItemPaged + :rtype: AsyncItemPaged :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: @@ -429,7 +429,7 @@ async def delete_message( @distributed_trace def list_participants( self, - **kwargs + **kwargs: Any ) -> AsyncItemPaged[ChatThreadParticipant]: """Gets the participants of a thread. @@ -437,7 +437,7 @@ def list_participants( :keyword int skip: Skips participants up to a specified position in response. :keyword callable cls: A custom type or function that will be passed the direct response :return: AsyncItemPaged[:class:`~azure.communication.chat.ChatThreadParticipant`] - :rtype: ~azure.core.async_paging.AsyncItemPaged + :rtype: AsyncItemPaged :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: From 8cd29d1615da3ca5cb321e37dc6cc367c3b8429e Mon Sep 17 00:00:00 2001 From: Rajarshi Sarkar <73562869+sarkar-rajarshi@users.noreply.github.com> Date: Thu, 4 Feb 2021 20:45:52 -0800 Subject: [PATCH 2/2] apiview fixes - Add missing type hints - return ItemPaged or AsyncItemPaged instead of full classpath --- .../azure/communication/chat/_chat_client.py | 5 ++--- .../communication/chat/_chat_thread_client.py | 12 +++++------ .../chat/aio/_chat_client_async.py | 20 +++++++++++++------ .../chat/aio/_chat_thread_client_async.py | 20 +++++++++---------- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_client.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_client.py index 5b685d03381b..af1ad4f897a2 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_client.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_client.py @@ -222,9 +222,8 @@ def list_chat_threads( :keyword int results_per_page: The maximum number of chat threads returned per page. :keyword ~datetime.datetime start_time: The earliest point in time to get chat threads up to. - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ItemPaged[:class:`~azure.communication.chat.ChatThreadInfo`] - :rtype: ItemPaged + :return: An iterator like instance of ChatThreadInfo + :rtype: ~azure.core.paging.ItemPaged[~azure.communication.chat.ChatThreadInfo] :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py index 49b7ca5ca604..1e3095997cf6 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py @@ -191,8 +191,8 @@ def list_read_receipts( :keyword int results_per_page: The maximum number of chat message read receipts to be returned per page. :keyword int skip: Skips chat message read receipts up to a specified position in response. :keyword callable cls: A custom type or function that will be passed the direct response - :return: ItemPaged[:class:`~azure.communication.chat.ChatMessageReadReceipt`] - :rtype: ItemPaged + :return: An iterator like instance of ChatMessageReadReceipt + :rtype: ~azure.core.paging.ItemPaged[~azure.communication.chat.ChatMessageReadReceipt] :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: @@ -341,8 +341,8 @@ def list_messages( :keyword int results_per_page: The maximum number of messages to be returned per page. :keyword ~datetime.datetime start_time: The start time where the range query. :keyword callable cls: A custom type or function that will be passed the direct response - :return: ItemPaged[:class:`~azure.communication.chat.ChatMessage`] - :rtype: ItemPaged + :return: An iterator like instance of ChatMessage + :rtype: ~azure.core.paging.ItemPaged[~azure.communication.chat.ChatMessage] :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: @@ -448,8 +448,8 @@ def list_participants( :keyword int results_per_page: The maximum number of participants to be returned per page. :keyword int skip: Skips participants up to a specified position in response. :keyword callable cls: A custom type or function that will be passed the direct response - :return: ItemPaged[:class:`~azure.communication.chat.ChatThreadParticipant`] - :rtype: ItemPaged + :return: An iterator like instance of ChatThreadParticipant + :rtype: ~azure.core.paging.ItemPaged[~azure.communication.chat.ChatThreadParticipant] :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_client_async.py b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_client_async.py index ae28ce325d0b..afd984be57ff 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_client_async.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_client_async.py @@ -61,6 +61,8 @@ def __init__( credential: CommunicationTokenCredential, **kwargs: Any ) -> None: + # type: (...) -> None + if not credential: raise ValueError("credential can not be None") @@ -85,9 +87,11 @@ def __init__( @distributed_trace def get_chat_thread_client( - self, thread_id: str, - **kwargs: Any + self, thread_id: str, + **kwargs: Any ) -> ChatThreadClient: + + # type: (...) -> ChatThreadClient """ Get ChatThreadClient by providing a thread_id. @@ -123,6 +127,9 @@ async def create_chat_thread( repeatability_request_id: Optional[str] = None, **kwargs ) -> ChatThreadClient: + + # type: (...) -> ChatThreadClient + """Creates a chat thread. :param topic: Required. The thread topic. @@ -185,7 +192,8 @@ async def create_chat_thread( async def get_chat_thread( self, thread_id: str, **kwargs - ) -> ChatThread: + ) -> ChatThread: # type: (...) -> ChatThread + """Gets a chat thread. :param thread_id: Required. Thread id to get. @@ -214,14 +222,14 @@ async def get_chat_thread( def list_chat_threads( self, **kwargs: Any - ) -> AsyncItemPaged[ChatThreadInfo]: + ): # type: (...) -> AsyncItemPaged[ChatThreadInfo] """Gets the list of chat threads of a user. :keyword int results_per_page: The maximum number of chat threads to be returned per page. :keyword ~datetime.datetime start_time: The earliest point in time to get chat threads up to. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncItemPaged[:class:`~azure.communication.chat.ChatThreadInfo`] - :rtype: AsyncItemPaged + :return: An iterator like instance of ChatThreadInfo + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.chat.ChatThreadInfo] :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py index 09f013752a48..aa057f11dd6f 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py @@ -74,7 +74,7 @@ def __init__( credential: CommunicationTokenCredential, thread_id: str, **kwargs: Any - ) -> None: + ): # type: (...) -> None if not thread_id: raise ValueError("thread_id can not be None or empty") @@ -181,13 +181,13 @@ async def send_read_receipt( def list_read_receipts( self, **kwargs: Any - ) -> AsyncItemPaged[ChatMessageReadReceipt]: + ): # type: (...) -> AsyncItemPaged[ChatMessageReadReceipt] """Gets read receipts for a thread. :keyword int results_per_page: The maximum number of chat message read receipts to be returned per page. :keyword int skip: Skips chat message read receipts up to a specified position in response. - :return: AsyncItemPaged[:class:`~azure.communication.chat.ChatMessageReadReceipt`] - :rtype: AsyncItemPaged + :return: An iterator like instance of ChatMessageReadReceipt + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.chat.ChatMessageReadReceipt] :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: @@ -326,14 +326,14 @@ async def get_message( def list_messages( self, **kwargs: Any - ) -> AsyncItemPaged[ChatMessage]: + ): # type: (...) -> AsyncItemPaged[ChatMessage] """Gets a list of messages from a thread. :keyword int results_per_page: The maximum number of messages to be returned per page. :keyword ~datetime.datetime start_time: The start time where the range query. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncItemPaged[:class:`~azure.communication.chat.ChatMessage`] - :rtype: AsyncItemPaged + :return: An iterator like instance of ChatMessage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.chat.ChatMessage] :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: @@ -430,14 +430,14 @@ async def delete_message( def list_participants( self, **kwargs: Any - ) -> AsyncItemPaged[ChatThreadParticipant]: + ): # type: (...) -> AsyncItemPaged[ChatThreadParticipant] """Gets the participants of a thread. :keyword int results_per_page: The maximum number of participants to be returned per page. :keyword int skip: Skips participants up to a specified position in response. :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncItemPaged[:class:`~azure.communication.chat.ChatThreadParticipant`] - :rtype: AsyncItemPaged + :return: An iterator like instance of ChatThreadParticipant + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.chat.ChatThreadParticipant] :raises: ~azure.core.exceptions.HttpResponseError, ValueError .. admonition:: Example: