Skip to content

Conversation

simorenoh
Copy link
Member

@simorenoh simorenoh commented Oct 3, 2025

Tackling the refactoring bullet-point from #43211. This PR refactors all instances of the typing module's Dict and List to the Python-native dict and list.

We are also changing the minimum Python version supported to 3.9 as per the Azure Core guidelines.

  • update CosmosDict and CosmosList to only inherit the built-in type for dict and list respectively instead of the current typing variant - as well as change List and Dict imports:
  • Updating the minimum Python version to 3.9 to align with Core SDKs guidelines.
image

Core dropped Python 3.8 already 6 months ago: #40831

@simorenoh simorenoh requested a review from a team as a code owner October 3, 2025 23:41
@Copilot Copilot AI review requested due to automatic review settings October 3, 2025 23:41
@github-actions github-actions bot added the Cosmos label Oct 3, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

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 refactors type hints throughout the Azure Cosmos DB SDK codebase to use native Python types dict and list instead of importing Dict and List from the typing module. This modernization aligns with Python 3.9+ best practices where the built-in collection types can be used directly as generic types.

  • Updates all type annotations from Dict[...] to dict[...] and List[...] to list[...]
  • Removes unused imports of Dict and List from typing modules
  • Maintains backward compatibility while modernizing the codebase

Reviewed Changes

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

Show a summary per file
File Description
test files Updated type hints in test files and fault injection transport
core API files Modernized type annotations in user.py, scripts.py, partition_key.py
database.py Updated all Dict/List type hints to use native dict/list types
cosmos_client.py Refactored type annotations throughout client connection code
container.py Updated extensive type hints for container operations and queries
async implementation files Modernized type hints in all async variants of core modules

@simorenoh simorenoh mentioned this pull request Oct 3, 2025
13 tasks
@simorenoh
Copy link
Member Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link

github-actions bot commented Oct 4, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure-cosmos

@simorenoh
Copy link
Member Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@allenkim0129 allenkim0129 left a comment

Choose a reason for hiding this comment

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

LGTM mostly, but got one comment for CosmosList.

Copy link
Contributor

@allenkim0129 allenkim0129 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@allenkim0129 allenkim0129 left a comment

Choose a reason for hiding this comment

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

LGTM

@simorenoh simorenoh merged commit 5bfecee into main Oct 7, 2025
21 checks passed
@simorenoh simorenoh deleted the dict-list-cosmos branch October 7, 2025 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants