Enable mypy static type checking for azure-communication-chat package #30
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 setting[tool.azure-sdk-build].mypy = truein the configuration and fixing all detected type annotation issues.Changes Made
1. Enable mypy checking
mypy = trueinpyproject.tomlto enable static type checking for the package2. Fix type annotations in utility files
_utils.py: Added proper type imports and fixed generic type annotationsTYPE_CHECKINGimports for forward referencesList,Tuple,Dicttype annotations..._communication_identifier_serializer.py: Fixed type annotation and None handling issuesDict[str, Any]type annotation for request_model3. Fix client type issues
_chat_thread_client.py: Fixed return type mismatches and missing importsChatError,CommunicationIdentifierModel)ItemPagedreturn type issues using type casting_chat_client.py: Similar fixes for chat clientChatThreadItemimportItemPagedmethods4. Fix async client type issues
aio/_chat_thread_client_async.py: Fixed async-specific type issuesOptional[str]andOptional[Dict[str, str]]where defaults areNoneAsyncItemPagedreturn type castingaio/_chat_client_async.py: Fixed async chat client issuesAsyncItemPagedreturns5. Fix shared dependencies
_shared/policy.py: Added type ignore for optionalyarlimportValidation
Testing
The package now has full mypy static type checking enabled with all type issues resolved while maintaining 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.