Skip to content

Commit c85bc1d

Browse files
cleemullinsChris MullinsCopilot
authored andcommitted
Update parameter type hints and documentation across multiple files for clarity and consistency. (#207)
* Update parameter type hints and documentation across multiple files for clarity and consistency. Fixes all 43 errors identified in issue #204 * Update libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/channel_service_adapter.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Chris Mullins <chmullins@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d34e62c commit c85bc1d

8 files changed

Lines changed: 204 additions & 148 deletions

File tree

libraries/microsoft-agents-activity/microsoft_agents/activity/channel_account.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ChannelAccount(AgentsModel):
1212
"""Channel account information needed to route a message.
1313
1414
:param id: Channel id for the user or agent on this channel (Example:
15-
joe@smith.com, or @joesmith or 123456)
15+
``joe@smith.com``, or ``@joesmith`` or ``123456``)
1616
:type id: str
1717
:param name: Display friendly name
1818
:type name: str

libraries/microsoft-agents-activity/microsoft_agents/activity/conversation_account.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ConversationAccount(AgentsModel):
1616
channels that distinguish between conversation types
1717
:type conversation_type: str
1818
:param id: Channel id for the user or agent on this channel (Example:
19-
joe@smith.com, or @joesmith or 123456)
19+
``joe@smith.com``, or ``@joesmith`` or ``123456``)
2020
:type id: str
2121
:param name: Display friendly name
2222
:type name: str

libraries/microsoft-agents-activity/microsoft_agents/activity/teams/teams_channel_account.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class TeamsChannelAccount(AgentsModel):
1010
"""Teams channel account detailing user Azure Active Directory details.
1111
12-
:param id: Channel id for the user or bot on this channel (Example: joe@smith.com, or @joesmith or 123456)
12+
:param id: Channel id for the user or bot on this channel (Example: ``joe@smith.com``, or ``@joesmith`` or ``123456``)
1313
:type id: str
1414
:param name: Display friendly name
1515
:type name: str

libraries/microsoft-agents-authentication-msal/microsoft_agents/authentication/msal/msal_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(self, msal_configuration: AgentAuthConfiguration):
5858
5959
:param msal_configuration: The MSAL authentication configuration. Assumed to
6060
not be mutated after being passed in.
61-
:type msal_configuration: AgentAuthConfiguration
61+
:type msal_configuration: :class:`microsoft_agents.hosting.core.authorization.agent_auth_configuration.AgentAuthConfiguration`
6262
"""
6363

6464
self._msal_configuration = msal_configuration

libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/activity_handler.py

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from __future__ import annotations
55
from http import HTTPStatus
6+
from typing import Awaitable
67
from pydantic import BaseModel
78

89
from microsoft_agents.activity import TurnContextProtocol
@@ -24,25 +25,26 @@ class ActivityHandler(Agent):
2425
"""
2526
Handles activities and should be subclassed.
2627
27-
.. remarks::
28+
.. note::
2829
Derive from this class to handle particular activity types.
29-
Yon can add pre and post processing of activities by calling the base class
30+
You can add pre and post processing of activities by calling the base class
3031
in the derived class.
3132
"""
3233

3334
async def on_turn(
3435
self, turn_context: TurnContextProtocol
3536
): # pylint: disable=arguments-differ
3637
"""
37-
Called by the adapter (for example, :class:`ChannelAdapter`) at runtime
38+
Called by the adapter (for example, :class:`microsoft_agents.hosting.core.channel_adapter.ChannelAdapter`) at runtime
3839
in order to process an inbound :class:`microsoft_agents.activity.Activity`.
3940
4041
:param turn_context: The context object for this turn
4142
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
4243
4344
:returns: A task that represents the work queued to execute
45+
:rtype: Awaitable[None]
4446
45-
.. remarks::
47+
.. note::
4648
It calls other methods in this class based on the type of the activity to
4749
process, which allows a derived class to provide type-specific logic in a controlled way.
4850
In a derived class, override this method to add logic that applies to all activity types.
@@ -108,6 +110,7 @@ async def on_message_activity( # pylint: disable=unused-argument
108110
:param turn_context: The context object for this turn
109111
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
110112
:returns: A task that represents the work queued to execute
113+
:rtype: Awaitable[None]
111114
"""
112115
return
113116

@@ -121,6 +124,7 @@ async def on_message_update_activity( # pylint: disable=unused-argument
121124
:param turn_context: The context object for this turn
122125
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
123126
:returns: A task that represents the work queued to execute
127+
:rtype: Awaitable[None]
124128
"""
125129
return
126130

@@ -134,6 +138,7 @@ async def on_message_delete_activity( # pylint: disable=unused-argument
134138
:param turn_context: The context object for this turn
135139
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
136140
:returns: A task that represents the work queued to execute
141+
:rtype: Awaitable[None]
137142
"""
138143
return
139144

@@ -145,17 +150,18 @@ async def on_conversation_update_activity(self, turn_context: TurnContextProtoco
145150
:param turn_context: The context object for this turn
146151
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
147152
:returns: A task that represents the work queued to execute
153+
:rtype: Awaitable[None]
148154
149-
.. remarks::
155+
.. note::
150156
When the :meth:`on_turn()` method receives a conversation update activity, it calls this
151157
method.
152158
Also
153159
- If the conversation update activity indicates that members other than the agent joined the conversation,
154-
it calls the :meth:`on_members_added_activity()` method.
160+
it calls the :meth:`on_members_added_activity()` method.
155161
- If the conversation update activity indicates that members other than the agent left the conversation,
156-
it calls the :meth:`on_members_removed_activity()` method.
162+
it calls the :meth:`on_members_removed_activity()` method.
157163
- In a derived class, override this method to add logic that applies to all conversation update activities.
158-
Add logic to apply before the member added or removed logic before the call to this base class method.
164+
Add logic to apply before the member added or removed logic before the call to this base class method.
159165
"""
160166
# TODO: confirm behavior of added and removed at the same time as C# doesn't support it
161167
if turn_context.activity.members_added:
@@ -175,13 +181,14 @@ async def on_members_added_activity(
175181
the conversation. You can add your agent's welcome logic.
176182
177183
:param members_added: A list of all the members added to the conversation, as described by the
178-
conversation update activity
184+
conversation update activity
179185
:type members_added: list[:class:`microsoft_agents.activity.ChannelAccount`]
180186
:param turn_context: The context object for this turn
181187
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
182188
:returns: A task that represents the work queued to execute
189+
:rtype: Awaitable[None]
183190
184-
.. remarks::
191+
.. note::
185192
When the :meth:`on_conversation_update_activity()` method receives a conversation
186193
update activity that indicates
187194
one or more users other than the agent are joining the conversation, it calls this method.
@@ -196,13 +203,14 @@ async def on_members_removed_activity(
196203
the conversation. You can add your agent's good-bye logic.
197204
198205
:param members_removed: A list of all the members removed from the conversation, as described by the
199-
conversation update activity
206+
conversation update activity
200207
:type members_removed: list[:class:`microsoft_agents.activity.ChannelAccount`]
201208
:param turn_context: The context object for this turn
202209
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
203210
:returns: A task that represents the work queued to execute
211+
:rtype: Awaitable[None]
204212
205-
.. remarks::
213+
.. note::
206214
When the :meth:`on_conversation_update_activity()` method receives a conversation
207215
update activity that indicates one or more users other than the agent are leaving the conversation,
208216
it calls this method.
@@ -219,8 +227,9 @@ async def on_message_reaction_activity(self, turn_context: TurnContextProtocol):
219227
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
220228
221229
:returns: A task that represents the work queued to execute
230+
:rtype: Awaitable[None]
222231
223-
.. remarks::
232+
.. note::
224233
Message reactions correspond to the user adding a 'like' or 'sad' etc. (often an emoji) to a previously
225234
sent activity.
226235
@@ -231,9 +240,9 @@ async def on_message_reaction_activity(self, turn_context: TurnContextProtocol):
231240
method.
232241
233242
- If the message reaction indicates that reactions were added to a message, it calls
234-
:meth:`on_reaction_added()`.
243+
:meth:`on_reactions_added()`.
235244
- If the message reaction indicates that reactions were removed from a message, it calls
236-
:meth:`on_reaction_removed()`.
245+
:meth:`on_reactions_removed()`.
237246
238247
In a derived class, override this method to add logic that applies to all message reaction activities.
239248
Add logic to apply before the reactions added or removed logic before the call to the this base class
@@ -264,8 +273,9 @@ async def on_reactions_added( # pylint: disable=unused-argument
264273
:param turn_context: The context object for this turn
265274
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
266275
:returns: A task that represents the work queued to execute
276+
:rtype: Awaitable[None]
267277
268-
.. remarks::
278+
.. note::
269279
Message reactions correspond to the user adding a 'like' or 'sad' etc. (often an emoji)
270280
to a previously sent message on the conversation.
271281
Message reactions are supported by only a few channels.
@@ -290,8 +300,9 @@ async def on_reactions_removed( # pylint: disable=unused-argument
290300
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
291301
292302
:returns: A task that represents the work queued to execute
303+
:rtype: Awaitable[None]
293304
294-
.. remarks::
305+
.. note::
295306
Message reactions correspond to the user adding a 'like' or 'sad' etc. (often an emoji)
296307
to a previously sent message on the conversation. Message reactions are supported by only a few channels.
297308
The activity that the message is in reaction to is identified by the activity's reply to Id property.
@@ -308,8 +319,9 @@ async def on_event_activity(self, turn_context: TurnContextProtocol):
308319
:param turn_context: The context object for this turn
309320
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
310321
:returns: A task that represents the work queued to execute
322+
:rtype: Awaitable[None]
311323
312-
.. remarks::
324+
.. note::
313325
When the :meth:`on_turn()` method receives an event activity, it calls this method.
314326
If the activity name is `tokens/response`, it calls :meth:`on_token_response_event()`;
315327
otherwise, it calls :meth:`on_event()`.
@@ -338,8 +350,9 @@ async def on_token_response_event( # pylint: disable=unused-argument
338350
:param turn_context: The context object for this turn
339351
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
340352
:returns: A task that represents the work queued to execute
353+
:rtype: Awaitable[None]
341354
342-
.. remarks::
355+
.. note::
343356
When the :meth:`on_event()` method receives an event with an activity name of
344357
`tokens/response`, it calls this method. If your agent uses an `oauth_prompt`, forward the incoming
345358
activity to the current dialog.
@@ -352,11 +365,13 @@ async def on_event( # pylint: disable=unused-argument
352365
"""
353366
Invoked when an event other than `tokens/response` is received when the base behavior of
354367
:meth:`on_event_activity()` is used.
368+
355369
:param turn_context: The context object for this turn
356370
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
357371
:returns: A task that represents the work queued to execute
372+
:rtype: Awaitable[None]
358373
359-
.. remarks::
374+
.. note::
360375
When the :meth:`on_event_activity()` is used method receives an event with an
361376
activity name other than `tokens/response`, it calls this method.
362377
This method could optionally be overridden if the agent is meant to handle miscellaneous events.
@@ -368,9 +383,11 @@ async def on_end_of_conversation_activity( # pylint: disable=unused-argument
368383
):
369384
"""
370385
Invoked when a conversation end activity is received from the channel.
386+
371387
:param turn_context: The context object for this turn
372388
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
373389
:returns: A task that represents the work queued to execute
390+
:rtype: Awaitable[None]
374391
"""
375392
return
376393

@@ -384,6 +401,7 @@ async def on_typing_activity( # pylint: disable=unused-argument
384401
:param turn_context: The context object for this turn
385402
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
386403
:returns: A task that represents the work queued to execute
404+
:rtype: Awaitable[None]
387405
"""
388406
return
389407

@@ -397,6 +415,7 @@ async def on_installation_update( # pylint: disable=unused-argument
397415
:param turn_context: The context object for this turn
398416
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
399417
:returns: A task that represents the work queued to execute
418+
:rtype: Awaitable[None]
400419
"""
401420
if turn_context.activity.action in ("add", "add-upgrade"):
402421
return await self.on_installation_update_add(turn_context)
@@ -414,6 +433,7 @@ async def on_installation_update_add( # pylint: disable=unused-argument
414433
:param turn_context: The context object for this turn
415434
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
416435
:returns: A task that represents the work queued to execute
436+
:rtype: Awaitable[None]
417437
"""
418438
return
419439

@@ -427,6 +447,7 @@ async def on_installation_update_remove( # pylint: disable=unused-argument
427447
:param turn_context: The context object for this turn
428448
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
429449
:returns: A task that represents the work queued to execute
450+
:rtype: Awaitable[None]
430451
"""
431452
return
432453

@@ -440,10 +461,10 @@ async def on_unrecognized_activity_type( # pylint: disable=unused-argument
440461
441462
:param turn_context: The context object for this turn
442463
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
443-
444464
:returns: A task that represents the work queued to execute
465+
:rtype: Awaitable[None]
445466
446-
.. remarks::
467+
.. note::
447468
When the :meth:`on_turn()` method receives an activity that is not a message,
448469
conversation update, message reaction, or event activity, it calls this method.
449470
"""
@@ -494,8 +515,8 @@ async def on_sign_in_invoke( # pylint: disable=unused-argument
494515
495516
:param turn_context: The context object for this turn
496517
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
497-
498518
:returns: A task that represents the work queued to execute
519+
:rtype: Awaitable[None]
499520
"""
500521
raise _InvokeResponseException(HTTPStatus.NOT_IMPLEMENTED)
501522

@@ -512,7 +533,7 @@ async def on_adaptive_card_invoke(
512533
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
513534
:param invoke_value: A string-typed object from the incoming activity's value.
514535
:type invoke_value: :class:`microsoft_agents.activity.AdaptiveCardInvokeValue`
515-
:return: The HealthCheckResponse object
536+
:returns: The HealthCheckResponse object
516537
:rtype: :class:`microsoft_agents.activity.AdaptiveCardInvokeResponse`
517538
"""
518539
raise _InvokeResponseException(HTTPStatus.NOT_IMPLEMENTED)

0 commit comments

Comments
 (0)