Skip to content

[Storage] [Named Keywords] Blob Package #41726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def upload_blob_to_url(
:rtype: dict(str, Any)
"""
with BlobClient.from_blob_url(blob_url, credential=credential) as client:
return cast(BlobClient, client).upload_blob(data=data, blob_type=BlobType.BLOCKBLOB, **kwargs)
return client.upload_blob(data=data, blob_type=BlobType.BLOCKBLOB, **kwargs)


def _download_to_stream(client: BlobClient, handle: IO[bytes], **kwargs: Any) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
# pylint: disable=too-many-lines, docstring-keyword-should-match-keyword-only

import warnings
from contextlib import AbstractContextManager
from datetime import datetime
from functools import partial
from typing import (
Any, AnyStr, cast, Dict, IO, Iterable, List, Optional, overload, Tuple, Union,
Any, AnyStr, cast, Dict, IO, Iterable, List, Optional, Tuple, Union,
TYPE_CHECKING
)
from typing_extensions import Self

from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError
from azure.core.paging import ItemPaged
Expand Down Expand Up @@ -89,7 +89,7 @@
)


class BlobClient(StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: disable=too-many-public-methods
class BlobClient(AbstractContextManager, StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: disable=too-many-public-methods
"""A client to interact with a specific blob, although that blob may not yet exist.

For more optional configuration, please click
Expand Down Expand Up @@ -190,7 +190,7 @@ def __init__(
self._client._config.version = get_api_version(kwargs) # type: ignore [assignment]
self._configure_encryption(kwargs)

def __enter__(self) -> Self:
def __enter__(self) -> "BlobClient":
self._client.__enter__()
return self

Expand Down Expand Up @@ -221,7 +221,7 @@ def from_blob_url(
credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
snapshot: Optional[Union[str, Dict[str, Any]]] = None,
**kwargs: Any
) -> Self:
) -> "BlobClient":
"""Create BlobClient from a blob url. This doesn't support customized blob url with '/' in blob name.

:param str blob_url:
Expand Down Expand Up @@ -269,7 +269,7 @@ def from_connection_string(
snapshot: Optional[Union[str, Dict[str, Any]]] = None,
credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
**kwargs: Any
) -> Self:
) -> "BlobClient":
"""Create BlobClient from a Connection String.

:param str conn_str:
Expand Down Expand Up @@ -633,26 +633,6 @@ def upload_blob(
return upload_page_blob(**options)
return upload_append_blob(**options)

@overload
def download_blob(
self, offset: Optional[int] = None,
length: Optional[int] = None,
*,
encoding: str,
**kwargs: Any
) -> StorageStreamDownloader[str]:
...

@overload
def download_blob(
self, offset: Optional[int] = None,
length: Optional[int] = None,
*,
encoding: None = None,
**kwargs: Any
) -> StorageStreamDownloader[bytes]:
...

@distributed_trace
def download_blob(
self, offset: Optional[int] = None,
Expand Down
Loading
Loading