-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Closed
Labels
ClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.Service AttentionWorkflow: This issue is responsible by Azure service team.Workflow: This issue is responsible by Azure service team.StorageStorage Service (Queues, Blobs, Files)Storage Service (Queues, Blobs, Files)bugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.
Description
- Package Name: azure-storage-blob
- Package Version: latest
- Operating System: macOS
- Python Version: Python 3.9
The async BlobClient class uses BlobClient (sync) as a mixin. The class method factories for instantiating the client, such as from_connection_string, from_blob_url have a type annotated return type as BlobClient, which is invalid:
The return type should be cls, using a TypeVar[T]. This ends up causing issues with type systems when you use the methods.
This simple example demonstrates the issue
from typing import Any, Dict
from azure.storage.blob.aio import (
BlobClient,
)
async def download_blob(blob_url: str) -> Any:
blob_client = BlobClient.from_blob_url(blob_url) # Has type BlobClient instead of AsyncBlobClient
response = await (await blob_client.download_blob()).readall() # Works but raises type errors
return responseAny type tool then causes issue because it thinks that blob_client is the sync client and not the async client.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.Service AttentionWorkflow: This issue is responsible by Azure service team.Workflow: This issue is responsible by Azure service team.StorageStorage Service (Queues, Blobs, Files)Storage Service (Queues, Blobs, Files)bugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.
