- Package Name:
azure-storage-blob
- Package Version: 12.9.0
Describe the bug
azure.storage.blob.BlobClient.upload_blob and the method that it wraps BlobClient._upload_blob_options both have the type annotation Union[Iterable[AnyStr], IO[AnyStr]] for the data argument.
|
def upload_blob( # pylint: disable=too-many-locals |
|
self, data, # type: Union[Iterable[AnyStr], IO[AnyStr]] |
|
blob_type=BlobType.BlockBlob, # type: Union[str, BlobType] |
|
length=None, # type: Optional[int] |
|
metadata=None, # type: Optional[Dict[str, str]] |
|
**kwargs |
|
): |
|
def _upload_blob_options( # pylint:disable=too-many-statements |
|
self, data, # type: Union[Iterable[AnyStr], IO[AnyStr]] |
|
blob_type=BlobType.BlockBlob, # type: Union[str, BlobType] |
|
length=None, # type: Optional[int] |
|
metadata=None, # type: Optional[Dict[str, str]] |
|
**kwargs |
|
): |
However, these methods also support cases where data is str or bytes.
This bit handles the case where data is str:
|
if isinstance(data, six.text_type): |
|
data = data.encode(encoding) # type: ignore |
and this bit handles the case where data is bytes:
|
if isinstance(data, bytes): |
|
stream = BytesIO(data) |
Expected behavior
The current annotation should be Union[AnyStr, Iterable[AnyStr], IO[AnyStr]].
azure-storage-blobDescribe the bug
azure.storage.blob.BlobClient.upload_bloband the method that it wrapsBlobClient._upload_blob_optionsboth have the type annotationUnion[Iterable[AnyStr], IO[AnyStr]]for thedataargument.azure-sdk-for-python/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py
Lines 573 to 579 in d720e56
azure-sdk-for-python/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py
Lines 339 to 345 in d720e56
However, these methods also support cases where data is
strorbytes.This bit handles the case where
dataisstr:azure-sdk-for-python/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py
Lines 361 to 362 in d720e56
and this bit handles the case where
dataisbytes:azure-sdk-for-python/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py
Lines 368 to 369 in d720e56
Expected behavior
The current annotation should be
Union[AnyStr, Iterable[AnyStr], IO[AnyStr]].