Skip to content

[Storage] Blob Typing Final Revision #35606

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

Merged
merged 54 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2e6ff88
[Storage] [Typing] Decouple `blob_client.py` and async (#33167)
vincenttran-msft Dec 4, 2023
1468747
[Storage] [Typing] Decouple `blob_service_client`.py and async (#33343)
vincenttran-msft Dec 4, 2023
799a385
[Storage] [Typing] Decouple `container_client.py` and async (#33304)
vincenttran-msft Dec 5, 2023
3d92fed
Merge branch 'main' into feature/storage-blob-typing2
vincenttran-msft Dec 5, 2023
ae195c2
[Storage] [Typing] All Blob Client helper `.py` files (#33428)
vincenttran-msft Dec 19, 2023
3372a74
[Storage] [Typing] [Blob] Misc files (`_serialize.py`, `_deserialize.…
vincenttran-msft Jan 24, 2024
3205ebf
[Storage] [Typing] [Blob] `_upload_helpers.py` and `_quick_query_help…
vincenttran-msft Jan 25, 2024
38f645f
[Storage] [Typing] [Blob] `_lease.py` and `_models.py` (and async/aio…
vincenttran-msft Jan 29, 2024
3616a82
[Storage] [Typing] [Blob] `_blob_client.py` (#33645)
vincenttran-msft Feb 7, 2024
269571a
[Storage] [Typing] [Blob] `_container_client.py` (#33650)
vincenttran-msft Feb 7, 2024
0af6f13
[Storage] [Typing] [Blob] `_blob_service_client.py` (#33662)
vincenttran-msft Feb 9, 2024
89c6266
[Storage] [Typing] [Blob] `blob_client_async.py` (#34236)
vincenttran-msft Feb 14, 2024
7d8a264
[Storage] [Typing] [Blob] `blob_service_client_async.py` (#34282)
vincenttran-msft Feb 14, 2024
342b895
[Storage] [Typing] [Blob] `__init__.py` and `__init__.py` aio (#34329)
vincenttran-msft Feb 23, 2024
bde0e37
[Storage] [Typing] [Blob] `container_client_async.py` (#34314)
vincenttran-msft Feb 27, 2024
90c59ff
True UTC datetime object conversion in blobs
vincenttran-msft Mar 22, 2024
ac6f092
Undo, wrong branch
vincenttran-msft Mar 22, 2024
1efceb9
[Storage] [Typing] [Blob] Fix up Blob Samples (#34929)
vincenttran-msft Mar 26, 2024
acb5cfe
[Storage] [Typing] [Blob] `_download_async.py` and miscellaneous rema…
vincenttran-msft Apr 15, 2024
f6e820d
Merge branch 'main' into feature/blob-typing
vincenttran-msft Apr 26, 2024
b4b17eb
[Storage] [Typing] [Blobs] Final Typing Sweep (#35393)
vincenttran-msft May 8, 2024
d5a53cf
Merge branch 'main' into feature/blob-typing
vincenttran-msft May 13, 2024
ed51e13
Enable mypy and samples type-checking thru pyproject.toml
vincenttran-msft May 13, 2024
c9d87b3
Fix delete_blobs helper
vincenttran-msft May 14, 2024
a4e8965
indents
vincenttran-msft May 14, 2024
2c68e83
Lint.
vincenttran-msft May 14, 2024
05a7572
Passing locally
vincenttran-msft May 15, 2024
664dfd4
Same blob batch fix to generate_set_tiers from delete_blobs
vincenttran-msft May 15, 2024
77562ab
PR feedback
vincenttran-msft May 21, 2024
5930d09
PR feedback
vincenttran-msft May 23, 2024
98c9474
Address FilteredBlob being returned in BSC, pass container=None
vincenttran-msft May 23, 2024
368b19a
PR feedback
vincenttran-msft May 29, 2024
338bbe9
Missed 1 model on Optional container revert
vincenttran-msft May 29, 2024
b5481b0
Nits
vincenttran-msft May 29, 2024
c01c00b
Add missing docstrings to models
vincenttran-msft Jun 14, 2024
4bb1bc4
Merge branch 'main' into feature/storage-blob-typing2
vincenttran-msft Jun 14, 2024
4c2be53
Merge branch 'main' into feature/blob-typing
vincenttran-msft Jun 18, 2024
1ce33d5
Download typed, 4 remaining errors
vincenttran-msft Jun 19, 2024
7e868f4
Remove unused Buffer
vincenttran-msft Jun 19, 2024
d753d21
Fix download sync 0 errors
vincenttran-msft Jun 21, 2024
8680867
async download
vincenttran-msft Jun 24, 2024
71fe9e7
Merge branch 'main' into feature/blob-typing
vincenttran-msft Jun 27, 2024
fe9ed1e
Merge branch 'main' into feature/blob-typing
vincenttran-msft Jul 9, 2024
f8cfe39
Merge branch 'main' into feature/blob-typing
vincenttran-msft Jul 10, 2024
53b7ec9
Enable strict sphinx in Blobs
vincenttran-msft Jul 10, 2024
7ed3afc
Add in strict sphinx to blob
vincenttran-msft Jul 10, 2024
43c8e22
strict-sphinx friendly
vincenttran-msft Jul 10, 2024
1ad8729
Nit
vincenttran-msft Jul 10, 2024
487ad13
Merge branch 'main' into feature/storage-blob-typing2
vincenttran-msft Jul 10, 2024
50fb7d5
Nit again
vincenttran-msft Jul 10, 2024
449fc17
Let's try list[] to List[] in docstring query_blob
vincenttran-msft Jul 11, 2024
7fc93db
Merge branch 'main' into feature/blob-typing
vincenttran-msft Jul 11, 2024
530c799
Nit
vincenttran-msft Jul 11, 2024
938a7d5
Merge branch 'main' into feature/storage-blob-typing2
vincenttran-msft Jul 18, 2024
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
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-blob/azure/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: str
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-blob/azure/storage/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: str
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
37 changes: 19 additions & 18 deletions sdk/storage/azure-storage-blob/azure/storage/blob/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import os

from typing import Union, Iterable, AnyStr, IO, Any, Dict # pylint: disable=unused-import
from typing import Any, AnyStr, cast, Dict, IO, Iterable, Optional, Union, TYPE_CHECKING
from ._version import VERSION
from ._blob_client import BlobClient
from ._container_client import ContainerClient
Expand All @@ -18,17 +18,15 @@
from ._shared_access_signature import generate_account_sas, generate_container_sas, generate_blob_sas
from ._shared.policies import ExponentialRetry, LinearRetry
from ._shared.response_handlers import PartialBatchErrorException
from ._shared.models import(
from ._shared.models import (
LocationMode,
ResourceTypes,
AccountSasPermissions,
StorageErrorCode,
UserDelegationKey,
Services
)
from ._generated.models import (
RehydratePriority,
)
from ._generated.models import RehydratePriority
from ._models import (
BlobType,
BlockState,
Expand Down Expand Up @@ -67,15 +65,18 @@
)
from ._list_blobs_helper import BlobPrefix

if TYPE_CHECKING:
from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential, TokenCredential

__version__ = VERSION


def upload_blob_to_url(
blob_url, # type: str
data, # type: Union[Iterable[AnyStr], IO[AnyStr]]
credential=None, # type: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
**kwargs):
# type: (...) -> Dict[str, Any]
blob_url: str,
data: Union[Iterable[AnyStr], IO[AnyStr]],
credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
**kwargs: Any
) -> Dict[str, Any]:
"""Upload data to a given URL

The data will be uploaded as a block blob.
Expand Down Expand Up @@ -125,10 +126,10 @@ def upload_blob_to_url(
:rtype: dict(str, Any)
"""
with BlobClient.from_blob_url(blob_url, credential=credential) as client:
return client.upload_blob(data=data, blob_type=BlobType.BlockBlob, **kwargs)
return cast(BlobClient, client).upload_blob(data=data, blob_type=BlobType.BLOCKBLOB, **kwargs)


def _download_to_stream(client, handle, **kwargs):
def _download_to_stream(client: BlobClient, handle: IO[bytes], **kwargs: Any) -> None:
"""
Download data to specified open file-handle.

Expand All @@ -140,11 +141,11 @@ def _download_to_stream(client, handle, **kwargs):


def download_blob_from_url(
blob_url, # type: str
output, # type: str
credential=None, # type: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
**kwargs):
# type: (...) -> None
blob_url: str,
output: Union[str, IO[bytes]],
credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
**kwargs: Any
) -> None:
"""Download the contents of a blob to a local file or stream.

:param str blob_url:
Expand Down Expand Up @@ -194,7 +195,7 @@ def download_blob_from_url(
overwrite = kwargs.pop('overwrite', False)
with BlobClient.from_blob_url(blob_url, credential=credential) as client:
if hasattr(output, 'write'):
_download_to_stream(client, output, **kwargs)
_download_to_stream(client, cast(IO[bytes], output), **kwargs)
else:
if not overwrite and os.path.isfile(output):
raise ValueError(f"The file '{output}' already exists.")
Expand Down
Loading