Skip to content

Linter issues - #485

Closed
Rodrigo Brandão (rodrigobr-msft) wants to merge 4 commits into
mainfrom
users/robrandao/linter
Closed

Linter issues#485
Rodrigo Brandão (rodrigobr-msft) wants to merge 4 commits into
mainfrom
users/robrandao/linter

Conversation

@rodrigobr-msft

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR primarily targets lint/type-check cleanliness across the Agents SDK Python packages, tightening type annotations, adding a few missing protocol members, and adjusting some runtime validation/response defaults in hosting-core and activity models.

Changes:

  • Refactors typing/annotations and small runtime validations across hosting-core (turn context, adapters, OAuth handlers, proactive helpers, and application wiring).
  • Adds/extends protocol surface area (e.g., close() on connector/user-token clients; stricter NotImplementedError stubs for protocol methods).
  • Introduces/uses new model utilities and channel-id helpers to normalize inputs and reduce None handling issues.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/turn_context.py Typing cleanup, plugin handler list typing, _emit refactor, and trace activity construction via pick_model.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/rest_channel_service_client_factory.py Improves agentic token acquisition by validating tenant ID once and reusing it.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/message_factory.py Refactors attachment helpers and input_hint typing/handling.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_http_adapter_base.py Adds HTTPStatus usage and defensive handling when invoke responses are absent.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/connector/user_token_client_base.py Extends protocol to require an async close() method.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/connector/connector_client_base.py Extends protocol to require an async close() method.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/client/channels_configuration.py Replaces pass with explicit NotImplementedError for protocol requirement clarity.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/client/channel_protocol.py Makes response_body_type explicitly optional in the protocol signature.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/client/channel_host_protocol.py Adds explicit protocol attributes for host/channel metadata.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/client/channel_factory_protocol.py Replaces pass with explicit NotImplementedError for protocol clarity.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/channel_service_adapter.py Tightens error types and type annotations for connector/user-token clients and invoke responses.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/channel_adapter.py Type/annotation fixes and conversation creation activity field updates.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/streaming/streaming_response.py Avoids runtime circular imports via TYPE_CHECKING and updates type hints.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/proactive/conversation.py Improves typing of identity extraction from turn state.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/authorization.py Minor robustness improvement for Teams channel detection.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/connector_user_authorization.py Adjusts OBO exchange return behavior to consistently return a TokenResponse.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/agentic_user_authorization.py Adds tenant-id validation and improved error logging/messages for agentic token retrieval.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/_user_authorization.py Strengthens turn-state requirements with casts and explicit missing-state errors.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/_authorization_handler.py Adds validation requiring settings when constructing the default handler.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/app_options.py Removes stray whitespace and keeps options clean for linting.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py Broad typing tweaks, storage wiring refactor, and deprecation marking for env parsing.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/_oauth/_oauth_flow.py Adds validation for token-exchange prerequisites and aligns return types.
libraries/microsoft-agents-copilotstudio-client/microsoft_agents/copilotstudio/client/power_platform_environment.py Fixes endpoint suffix lookup to raise on invalid cloud categories.
libraries/microsoft-agents-activity/microsoft_agents/activity/turn_context_protocol.py Simplifies protocol typing by removing the generic parameterization.
libraries/microsoft-agents-activity/microsoft_agents/activity/token_response.py Fixes exception handling/flow in is_exchangeable.
libraries/microsoft-agents-activity/microsoft_agents/activity/conversation_reference.py Refactors docs/type-checking structure and imports; keeps runtime behavior focused.
libraries/microsoft-agents-activity/microsoft_agents/activity/conversation_parameters.py Adds explicit conversation field and required import.
libraries/microsoft-agents-activity/microsoft_agents/activity/channels.py Adds ChannelId normalization support for capability checks.
libraries/microsoft-agents-activity/microsoft_agents/activity/channel_id.py Improves Optional typing and adds channel/sub-channel parsing helpers.
libraries/microsoft-agents-activity/microsoft_agents/activity/activity.py Reduces docstring verbosity and adds TYPE_CHECKING init signature for better typing.
libraries/microsoft-agents-activity/microsoft_agents/activity/_model_utils.py Improves generic typing for pick_model.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 10 to 14
from contextlib import nullcontext
from copy import copy
from functools import partial
from warnings import deprecated

Comment on lines 153 to 157
self._turn_state_factory = (
options.turn_state_factory
or kwargs.get("turn_state_factory", None)
or partial(TurnState.with_storage, self._options.storage)
or partial(StateT.with_storage, self._storage)
)
Comment on lines +155 to 161
if not input_hint:
return attachment_activity(
AttachmentLayoutTypes.list, attachments, text, speak
)
return attachment_activity(
AttachmentLayoutTypes.list, attachments, text, speak, input_hint
)
Comment on lines +191 to 197
if not input_hint:
return attachment_activity(
AttachmentLayoutTypes.carousel, attachments, text, speak
)
return attachment_activity(
AttachmentLayoutTypes.carousel, attachments, text, speak, input_hint
)
Comment on lines 102 to 106
return (
button_cnt <= max_actions[channel_id]
button_count <= max_actions[channel]
if channel_id in max_actions
else False
)
Comment on lines +333 to 335
handlers = list(plugins)

async def emit_next(i: int):
Comment on lines +70 to 76
identity: Optional[ClaimsIdentity] = cast(
ClaimsIdentity | None,
context.turn_state.get(
ChannelAdapter.AGENT_IDENTITY_KEY
))

reference = context.activity.get_conversation_reference()
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) deleted the users/robrandao/linter branch July 31, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants