Enable mypy static type checking for azure-communication-chat package #31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR enables mypy static type checking for the
azure-communication-chatpackage by settingmypy = truein the package'spyproject.tomlconfiguration and fixing all type annotation issues identified by mypy.Changes Made
Configuration
[tool.azure-sdk-build].mypy = trueinpyproject.tomlType Annotation Fixes
Core Utilities (
_utils.py)ChatParticipantandChatErrortypesNonevalues in error processingfailed_chat_thread_participantsCommunication Identifier Serializer (
_communication_identifier_serializer.py)Nonehandling for identifier propertiesClient Files
Sync Client (
_chat_thread_client.py,_chat_client.py):ItemPaged,ChatError,ChatThreadItem,CommunicationIdentifierModel)remove_chat_participantparameter type conversionAsync Client (
aio/_chat_thread_client_async.py,aio/_chat_client_async.py):Optionalparameter types (e.g.,topic: Optional[str] = None)AsyncItemPagedmethodsKey Technical Solutions
cast()to help mypy understand that generated client methods actually return the correctItemPaged/AsyncItemPagedtypesOptionalissues by explicitly marking parameters that can beNoneVerification
Impact
This change enables static type checking for the azure-communication-chat package, improving:
The package now complies with the Azure SDK for Python type checking standards while maintaining full backward compatibility.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.