From adab1e46dff63795b654336893c8e97bd7e64600 Mon Sep 17 00:00:00 2001 From: Chris Mullins Date: Wed, 8 Oct 2025 13:59:11 -0700 Subject: [PATCH 1/4] Update type hints to use 'Optional' consistently in docstrings. Note that casing here matters. --- .../microsoft_agents/hosting/core/_oauth/_oauth_flow.py | 2 +- .../hosting/core/app/agent_application.py | 8 ++++---- .../core/app/oauth/_handlers/_user_authorization.py | 4 ++-- .../app/oauth/_handlers/agentic_user_authorization.py | 6 +++--- .../hosting/core/app/oauth/authorization.py | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/_oauth/_oauth_flow.py b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/_oauth/_oauth_flow.py index a3a9c808..b7863faf 100644 --- a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/_oauth/_oauth_flow.py +++ b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/_oauth/_oauth_flow.py @@ -112,7 +112,7 @@ async def get_user_token(self, magic_code: str = None) -> TokenResponse: """Get the user token based on the context. Args: - magic_code (str, optional): Defaults to None. The magic code for user authentication. + magic_code (str, Optional): Defaults to None. The magic code for user authentication. Returns: TokenResponse diff --git a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py index 0184965d..14bc2b06 100644 --- a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py +++ b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py @@ -221,14 +221,14 @@ def add_route( :param handler: A function that takes a TurnContext and a TurnState and returns an Awaitable. :type handler: RouteHandler[StateT] :param is_invoke: Whether the route is for an invoke activity, defaults to False - :type is_invoke: bool, optional + :type is_invoke: bool, Optional :param is_agentic: Whether the route is for an agentic request, defaults to False. For agentic requests the selector will include a new check for `context.activity.is_agentic_request()`. - :type is_agentic: bool, optional + :type is_agentic: bool, Optional :param rank: The rank of the route, defaults to RouteRank.DEFAULT - :type rank: RouteRank, optional + :type rank: RouteRank, Optional :param auth_handlers: A list of authentication handler IDs to use for this route, defaults to None - :type auth_handlers: Optional[list[str]], optional + :type auth_handlers: Optional[list[str]], Optional :raises ApplicationError: If the selector or handler are not valid. """ if not selector or not handler: diff --git a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/_user_authorization.py b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/_user_authorization.py index 118bad53..902b0dd4 100644 --- a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/_user_authorization.py +++ b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/_user_authorization.py @@ -249,9 +249,9 @@ async def get_refreshed_token( :param context: The turn context for the current turn of conversation. :type context: TurnContext :param exchange_connection: Optional name of the connection to use for token exchange. If None, default connection will be used. - :type exchange_connection: Optional[str], optional + :type exchange_connection: Optional[str], Optional :param exchange_scopes: Optional list of scopes to request during token exchange. If None, default scopes will be used. - :type exchange_scopes: Optional[list[str]], optional + :type exchange_scopes: Optional[list[str]], Optional """ flow, _ = await self._load_flow(context) input_token_response = await flow.get_user_token() diff --git a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/agentic_user_authorization.py b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/agentic_user_authorization.py index 847aedba..7c8a5a30 100644 --- a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/agentic_user_authorization.py +++ b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/agentic_user_authorization.py @@ -41,7 +41,7 @@ def __init__( :param connection_manager: The connection manager for OAuth providers. :type connection_manager: Connections :param auth_handlers: Configuration for OAuth providers. - :type auth_handlers: dict[str, AuthHandler], optional + :type auth_handlers: dict[str, AuthHandler], Optional :raises ValueError: When storage is None or no auth handlers provided. """ super().__init__( @@ -172,9 +172,9 @@ async def get_refreshed_token( :param context: The turn context for the current turn of conversation. :type context: TurnContext :param exchange_connection: Optional name of the connection to use for token exchange. If None, default connection will be used. - :type exchange_connection: Optional[str], optional + :type exchange_connection: Optional[str], Optional :param exchange_scopes: Optional list of scopes to request during token exchange. If None, default scopes will be used. - :type exchange_scopes: Optional[list[str]], optional + :type exchange_scopes: Optional[list[str]], Optional """ if not exchange_scopes: exchange_scopes = self._handler.scopes or [] diff --git a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/authorization.py b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/authorization.py index f5bd8f56..cf6025be 100644 --- a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/authorization.py +++ b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/authorization.py @@ -59,7 +59,7 @@ def __init__( :param connection_manager: The connection manager for OAuth providers. :type connection_manager: Connections :param auth_handlers: Configuration for OAuth providers. - :type auth_handlers: dict[str, AuthHandler], optional + :type auth_handlers: dict[str, AuthHandler], Optional :raises ValueError: When storage is None or no auth handlers provided. """ if not storage: From 1fd9b3c3c4ac044f25bc75417c49a1ec811d8814 Mon Sep 17 00:00:00 2001 From: Chris Mullins Date: Wed, 8 Oct 2025 14:08:52 -0700 Subject: [PATCH 2/4] Update type hints for turn_context parameter to use TurnContextProtocol consistently --- .../hosting/core/activity_handler.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/activity_handler.py b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/activity_handler.py index 483cb6e9..2f6db134 100644 --- a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/activity_handler.py +++ b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/activity_handler.py @@ -38,7 +38,7 @@ async def on_turn( in order to process an inbound :class:`microsoft_agents.activity.Activity`. :param turn_context: The context object for this turn - :type turn_context: :class:`microsoft_agents.builder.TurnContext` + :type turn_context: :class:`microsoft_agents.builder.TurnContextProtocol` :returns: A task that represents the work queued to execute @@ -143,7 +143,7 @@ async def on_conversation_update_activity(self, turn_context: TurnContextProtoco :meth:`on_turn()` is used. :param turn_context: The context object for this turn - :type turn_context: :class:`microsoft_agents.builder.TurnContext` + :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol` :returns: A task that represents the work queued to execute .. remarks:: @@ -216,7 +216,7 @@ async def on_message_reaction_activity(self, turn_context: TurnContextProtocol): :meth:`on_turn()` is used. :param turn_context: The context object for this turn - :type turn_context: :class:`microsoft_agents.builder.TurnContext` + :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol` :returns: A task that represents the work queued to execute @@ -382,7 +382,7 @@ async def on_typing_activity( # pylint: disable=unused-argument ActivityTypes.typing activities, such as the conversational logic. :param turn_context: The context object for this turn - :type turn_context: :class:`microsoft_agents.builder.TurnContext` + :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol` :returns: A task that represents the work queued to execute """ return @@ -395,7 +395,7 @@ async def on_installation_update( # pylint: disable=unused-argument ActivityTypes.InstallationUpdate activities. :param turn_context: The context object for this turn - :type turn_context: :class:`microsoft_agents.builder.TurnContext` + :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol` :returns: A task that represents the work queued to execute """ if turn_context.activity.action in ("add", "add-upgrade"): @@ -412,7 +412,7 @@ async def on_installation_update_add( # pylint: disable=unused-argument ActivityTypes.InstallationUpdate activities with 'action' set to 'add'. :param turn_context: The context object for this turn - :type turn_context: :class:`microsoft_agents.builder.TurnContext` + :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol` :returns: A task that represents the work queued to execute """ return @@ -425,7 +425,7 @@ async def on_installation_update_remove( # pylint: disable=unused-argument ActivityTypes.InstallationUpdate activities with 'action' set to 'remove'. :param turn_context: The context object for this turn - :type turn_context: :class:`microsoft_agents.builder.TurnContext` + :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol` :returns: A task that represents the work queued to execute """ return @@ -439,7 +439,7 @@ async def on_unrecognized_activity_type( # pylint: disable=unused-argument If overridden, this method could potentially respond to any of the other activity types. :param turn_context: The context object for this turn - :type turn_context: :class:`microsoft_agents.builder.TurnContext` + :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol` :returns: A task that represents the work queued to execute @@ -456,7 +456,7 @@ async def on_invoke_activity( # pylint: disable=unused-argument Registers an activity event handler for the _invoke_ event, emitted for every incoming event activity. :param turn_context: The context object for this turn - :type turn_context: :class:`microsoft_agents.builder.TurnContext` + :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol` :returns: A task that represents the work queued to execute """ @@ -492,7 +492,7 @@ async def on_sign_in_invoke( # pylint: disable=unused-argument By default, this method does nothing. :param turn_context: The context object for this turn - :type turn_context: :class:`microsoft_agents.builder.TurnContext` + :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol` :returns: A task that represents the work queued to execute """ @@ -508,7 +508,7 @@ async def on_adaptive_card_invoke( calls this method. :param turn_context: A context object for this turn. - :type turn_context: :class:`microsoft_agents.builder.TurnContext` + :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol` :param invoke_value: A string-typed object from the incoming activity's value. :type invoke_value: :class:`microsoft_agents.activity.adaptive_card_invoke_value.AdaptiveCardInvokeValue` :return: The HealthCheckResponse object From 20b3157a1d2b02c00e98d9388d79473b85550a15 Mon Sep 17 00:00:00 2001 From: Chris Mullins Date: Wed, 8 Oct 2025 14:16:52 -0700 Subject: [PATCH 3/4] Update type hints to use 'Optional' consistently in parameter annotations --- .../microsoft_agents/activity/channels.py | 4 ++-- .../core/app/oauth/_handlers/_authorization_handler.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/microsoft-agents-activity/microsoft_agents/activity/channels.py b/libraries/microsoft-agents-activity/microsoft_agents/activity/channels.py index d6172a43..d0a8a764 100644 --- a/libraries/microsoft-agents-activity/microsoft_agents/activity/channels.py +++ b/libraries/microsoft-agents-activity/microsoft_agents/activity/channels.py @@ -74,7 +74,7 @@ def supports_suggested_actions(channel_id: Self, button_cnt: int = 100) -> bool: Args: channel_id (str): The Channel to check the if Suggested Actions are supported in. - button_cnt (int, optional): Defaults to 100. The number of Suggested Actions to check for the Channel. + button_cnt (int, Optional): Defaults to 100. The number of Suggested Actions to check for the Channel. Returns: bool: True if the Channel supports the button_cnt total Suggested Actions, False if the Channel does not @@ -107,7 +107,7 @@ def supports_card_actions(channel_id: Self, button_cnt: int = 100) -> bool: Args: channel_id (str): The Channel to check if the Card Actions are supported in. - button_cnt (int, optional): Defaults to 100. The number of Card Actions to check for the Channel. + button_cnt (int, Optional): Defaults to 100. The number of Card Actions to check for the Channel. Returns: bool: True if the Channel supports the button_cnt total Card Actions, False if the Channel does not support diff --git a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/_authorization_handler.py b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/_authorization_handler.py index 66894d76..542b74cb 100644 --- a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/_authorization_handler.py +++ b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/_authorization_handler.py @@ -43,7 +43,7 @@ def __init__( :param connection_manager: The connection manager for OAuth providers. :type connection_manager: Connections :param auth_handlers: Configuration for OAuth providers. - :type auth_handlers: dict[str, AuthHandler], optional + :type auth_handlers: dict[str, AuthHandler], Optional :raises ValueError: When storage is None or no auth handlers provided. """ if not storage: @@ -75,7 +75,7 @@ async def _sign_in( :param context: The turn context for the current turn of conversation. :type context: TurnContext :param scopes: Optional list of scopes to request during sign-in. If None, default scopes will be used. - :type scopes: Optional[list[str]], optional + :type scopes: Optional[list[str]], Optional :return: A SignInResponse indicating the result of the sign-in attempt. :rtype: SignInResponse """ @@ -92,9 +92,9 @@ async def get_refreshed_token( :param context: The turn context for the current turn of conversation. :type context: TurnContext :param exchange_connection: Optional name of the connection to use for token exchange. If None, default connection will be used. - :type exchange_connection: Optional[str], optional + :type exchange_connection: Optional[str], Optional :param exchange_scopes: Optional list of scopes to request during token exchange. If None, default scopes will be used. - :type exchange_scopes: Optional[list[str]], optional + :type exchange_scopes: Optional[list[str]], Optional """ raise NotImplementedError() From 7a7933a06e2cc5047be3ee3772b9771fbdb84c64 Mon Sep 17 00:00:00 2001 From: Chris Mullins Date: Wed, 8 Oct 2025 14:28:54 -0700 Subject: [PATCH 4/4] Fix type hint reference for turn_context parameter in ActivityHandler docstring --- .../microsoft_agents/hosting/core/activity_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/activity_handler.py b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/activity_handler.py index 2f6db134..00c745eb 100644 --- a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/activity_handler.py +++ b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/activity_handler.py @@ -38,7 +38,7 @@ async def on_turn( in order to process an inbound :class:`microsoft_agents.activity.Activity`. :param turn_context: The context object for this turn - :type turn_context: :class:`microsoft_agents.builder.TurnContextProtocol` + :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol` :returns: A task that represents the work queued to execute