Skip to content

Commit 526d2eb

Browse files
author
Michael Miele
committed
Update bot_framework_adapter.py
Code comments formatting and replaced remarks with note in methods.
1 parent e03f7e1 commit 526d2eb

File tree

1 file changed

+48
-31
lines changed

1 file changed

+48
-31
lines changed

libraries/botbuilder-core/botbuilder/core/bot_framework_adapter.py

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def __init__(
8383
channel_provider: ChannelProvider = None,
8484
auth_configuration: AuthenticationConfiguration = None,
8585
):
86-
"""Contains the settings used to initialize a :class:`BotFrameworkAdapter` instance.
86+
"""
87+
Contains the settings used to initialize a :class:`BotFrameworkAdapter` instance.
8788
8889
:param app_id: The bot application ID. This is the appId returned by the Azure portal registration, and is
8990
the value of the `MicrosoftAppId` parameter in the `config.py` file.
@@ -116,7 +117,8 @@ def __init__(
116117

117118

118119
class BotFrameworkAdapter(BotAdapter, UserTokenProvider):
119-
"""Defines an adapter to connect a bot to a service endpoint
120+
"""
121+
Defines an adapter to connect a bot to a service endpoint.
120122
121123
.. remarks::
122124
The bot adapter encapsulates authentication processes and sends activities to and
@@ -132,10 +134,11 @@ class BotFrameworkAdapter(BotAdapter, UserTokenProvider):
132134
_INVOKE_RESPONSE_KEY = "BotFrameworkAdapter.InvokeResponse"
133135

134136
def __init__(self, settings: BotFrameworkAdapterSettings):
135-
""" Initializes a new instance of the :class:`BotFrameworkAdapter` class
137+
"""
138+
Initializes a new instance of the :class:`BotFrameworkAdapter` class.
136139
137-
:param settings: The settings to initialize the adapter
138-
:type settings: :class:`BotFrameworkAdapterSettings`
140+
:param settings: The settings to initialize the adapter
141+
:type settings: :class:`BotFrameworkAdapterSettings`
139142
"""
140143
super(BotFrameworkAdapter, self).__init__()
141144
self.settings = settings or BotFrameworkAdapterSettings("", "")
@@ -180,7 +183,8 @@ async def continue_conversation(
180183
bot_id: str = None,
181184
claims_identity: ClaimsIdentity = None, # pylint: disable=unused-argument
182185
):
183-
"""Continues a conversation with a user
186+
"""
187+
Continues a conversation with a user.
184188
185189
:param reference: A reference to the conversation to continue
186190
:type reference: :class:`botbuilder.schema.ConversationReference
@@ -192,11 +196,11 @@ async def continue_conversation(
192196
:param claims_identity: The bot claims identity
193197
:type claims_identity: :class:`botframework.connector.auth.ClaimsIdentity`
194198
195-
:raises: It raises an argument null exception
199+
:raises: It raises an argument null exception.
196200
197-
:return: A task that represents the work queued to execute
201+
:return: A task that represents the work queued to execute.
198202
199-
.. remarks::
203+
.. note::
200204
This is often referred to as the bots *proactive messaging* flow as it lets the bot proactively
201205
send messages to a conversation or user that are already in a communication.
202206
Scenarios such as sending notifications or coupons to a user are enabled by this function.
@@ -225,20 +229,21 @@ async def create_conversation(
225229
logic: Callable[[TurnContext], Awaitable] = None,
226230
conversation_parameters: ConversationParameters = None,
227231
):
228-
"""Starts a new conversation with a user
229-
Used to direct message to a member of a group
232+
"""
233+
Starts a new conversation with a user. Used to direct message to a member of a group.
234+
230235
:param reference: The conversation reference that contains the tenant
231236
:type reference: :class:`botbuilder.schema.ConversationReference`
232237
:param logic: The logic to use for the creation of the conversation
233238
:type logic: :class:`typing.Callable`
234239
:param conversation_parameters: The information to use to create the conversation
235240
:type conversation_parameters:
236241
237-
:raises: It raises a generic exception error
242+
:raises: It raises a generic exception error.
238243
239-
:return: A task representing the work queued to execute
244+
:return: A task representing the work queued to execute.
240245
241-
.. remarks::
246+
.. note::
242247
To start a conversation, your bot must know its account information and the user's
243248
account information on that channel.
244249
Most channels only support initiating a direct message (non-group) conversation.
@@ -296,7 +301,8 @@ async def create_conversation(
296301
raise error
297302

298303
async def process_activity(self, req, auth_header: str, logic: Callable):
299-
"""Creates a turn context and runs the middleware pipeline for an incoming activity
304+
"""
305+
Creates a turn context and runs the middleware pipeline for an incoming activity,
300306
Processes an activity received by the bots web server. This includes any messages sent from a
301307
user and is the method that drives what's often referred to as the bots *reactive messaging* flow.
302308
@@ -311,7 +317,7 @@ async def process_activity(self, req, auth_header: str, logic: Callable):
311317
was `Invoke` and the corresponding key (`channelId` + `activityId`) was found then
312318
an :class:`InvokeResponse` is returned; otherwise, `null` is returned.
313319
314-
.. remarks::
320+
.. note::
315321
Call this method to reactively send a message to a conversation.
316322
If the task completes successfully, then an :class:`InvokeResponse` is returned;
317323
otherwise. `null` is returned.
@@ -356,12 +362,14 @@ async def process_activity(self, req, auth_header: str, logic: Callable):
356362
async def authenticate_request(
357363
self, request: Activity, auth_header: str
358364
) -> ClaimsIdentity:
359-
"""Allows for the overriding of authentication in unit tests.
365+
"""
366+
Allows for the overriding of authentication in unit tests.
367+
360368
:param request: The request to authenticate
361369
:type request: :class:`botbuilder.schema.Activity`
362370
:param auth_header: The authentication header
363371
364-
:raises: A permission exception error
372+
:raises: A permission exception error.
365373
366374
:return: The request claims identity
367375
:rtype: :class:`botframework.connector.auth.ClaimsIdentity`
@@ -383,7 +391,7 @@ def create_context(self, activity):
383391
"""
384392
Allows for the overriding of the context object in unit tests and derived adapters.
385393
:param activity:
386-
:return:
394+
:return:
387395
"""
388396
return TurnContext(self, activity)
389397

@@ -445,7 +453,7 @@ async def update_activity(self, context: TurnContext, activity: Activity):
445453
446454
:return: A task that represents the work queued to execute
447455
448-
.. remarks::
456+
.. note::
449457
If the activity is successfully sent, the task result contains
450458
a :class:`botbuilder.schema.ResourceResponse` object containing the ID that
451459
the receiving channel assigned to the activity.
@@ -477,7 +485,7 @@ async def delete_activity(
477485
478486
:return: A task that represents the work queued to execute
479487
480-
.. remarks::
488+
.. note::
481489
The activity_id of the :class:`botbuilder.schema.ConversationReference` identifies the activity to delete.
482490
"""
483491
try:
@@ -549,7 +557,9 @@ async def send_activities(
549557
async def delete_conversation_member(
550558
self, context: TurnContext, member_id: str
551559
) -> None:
552-
"""Deletes a member from the current conversation
560+
"""
561+
Deletes a member from the current conversation.
562+
553563
:param context: The context object for the turn
554564
:type context: :class:`TurnContext`
555565
:param member_id: The ID of the member to remove from the conversation
@@ -585,7 +595,8 @@ async def delete_conversation_member(
585595
raise error
586596

587597
async def get_activity_members(self, context: TurnContext, activity_id: str):
588-
"""Lists the members of a given activity
598+
"""
599+
Lists the members of a given activity.
589600
590601
:param context: The context object for the turn
591602
:type context: :class:`TurnContext`
@@ -626,7 +637,8 @@ async def get_activity_members(self, context: TurnContext, activity_id: str):
626637
raise error
627638

628639
async def get_conversation_members(self, context: TurnContext):
629-
"""Lists the members of a current conversation.
640+
"""
641+
Lists the members of a current conversation.
630642
631643
:param context: The context object for the turn
632644
:type context: :class:`TurnContext`
@@ -672,7 +684,7 @@ async def get_conversations(self, service_url: str, continuation_token: str = No
672684
673685
:return: A task that represents the work queued to execute
674686
675-
.. remarks:: If the task completes successfully, the result contains a page of the members of the current conversation.
687+
.. note:: If the task completes successfully, the result contains a page of the members of the current conversation.
676688
This overload may be called from outside the context of a conversation, as only the bot's service URL and credentials are required.
677689
"""
678690
client = await self.create_connector_client(service_url)
@@ -682,7 +694,8 @@ async def get_user_token(
682694
self, context: TurnContext, connection_name: str, magic_code: str = None
683695
) -> TokenResponse:
684696

685-
"""Attempts to retrieve the token for a user that's in a login flow
697+
"""
698+
Attempts to retrieve the token for a user that's in a login flow.
686699
687700
:param context: Context for the current turn of conversation with the user
688701
:type context: :class:`TurnContext`
@@ -728,7 +741,8 @@ async def get_user_token(
728741
async def sign_out_user(
729742
self, context: TurnContext, connection_name: str = None, user_id: str = None
730743
) -> str:
731-
"""Signs the user out with the token server
744+
"""
745+
Signs the user out with the token server.
732746
733747
:param context: Context for the current turn of conversation with the user
734748
:type context: :class:`TurnContext`
@@ -756,7 +770,8 @@ async def sign_out_user(
756770
async def get_oauth_sign_in_link(
757771
self, context: TurnContext, connection_name: str
758772
) -> str:
759-
"""Gets the raw sign-in link to be sent to the user for sign-in for a connection name.
773+
"""
774+
Gets the raw sign-in link to be sent to the user for sign-in for a connection name.
760775
761776
:param context: Context for the current turn of conversation with the user
762777
:type context: :class:`TurnContext`
@@ -765,7 +780,7 @@ async def get_oauth_sign_in_link(
765780
766781
:returns: A task that represents the work queued to execute
767782
768-
.. remarks::
783+
.. note::
769784
If the task completes successfully, the result contains the raw sign-in link
770785
"""
771786
self.check_emulating_oauth_cards(context)
@@ -788,7 +803,8 @@ async def get_token_status(
788803
self, context: TurnContext, user_id: str = None, include_filter: str = None
789804
) -> List[TokenStatus]:
790805

791-
"""Retrieves the token status for each configured connection for the given user
806+
"""
807+
Retrieves the token status for each configured connection for the given user.
792808
793809
:param context: Context for the current turn of conversation with the user
794810
:type context: :class:`TurnContext`
@@ -821,7 +837,8 @@ async def get_token_status(
821837
async def get_aad_tokens(
822838
self, context: TurnContext, connection_name: str, resource_urls: List[str]
823839
) -> Dict[str, TokenResponse]:
824-
"""Retrieves Azure Active Directory tokens for particular resources on a configured connection
840+
"""
841+
Retrieves Azure Active Directory tokens for particular resources on a configured connection.
825842
826843
:param context: Context for the current turn of conversation with the user
827844
:type context: :class:`TurnContext`

0 commit comments

Comments
 (0)