azure-storage-blob 12.21.0b1__py3-none-any.whl → 12.23.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. azure/storage/blob/__init__.py +19 -18
  2. azure/storage/blob/_blob_client.py +470 -1555
  3. azure/storage/blob/_blob_client_helpers.py +1242 -0
  4. azure/storage/blob/_blob_service_client.py +93 -112
  5. azure/storage/blob/_blob_service_client_helpers.py +27 -0
  6. azure/storage/blob/_container_client.py +176 -377
  7. azure/storage/blob/_container_client_helpers.py +266 -0
  8. azure/storage/blob/_deserialize.py +68 -44
  9. azure/storage/blob/_download.py +375 -241
  10. azure/storage/blob/_encryption.py +14 -7
  11. azure/storage/blob/_generated/_azure_blob_storage.py +2 -1
  12. azure/storage/blob/_generated/_serialization.py +2 -0
  13. azure/storage/blob/_generated/aio/_azure_blob_storage.py +2 -1
  14. azure/storage/blob/_generated/aio/operations/_append_blob_operations.py +1 -7
  15. azure/storage/blob/_generated/aio/operations/_blob_operations.py +21 -47
  16. azure/storage/blob/_generated/aio/operations/_block_blob_operations.py +2 -10
  17. azure/storage/blob/_generated/aio/operations/_container_operations.py +13 -26
  18. azure/storage/blob/_generated/aio/operations/_page_blob_operations.py +3 -14
  19. azure/storage/blob/_generated/aio/operations/_service_operations.py +14 -17
  20. azure/storage/blob/_generated/operations/_append_blob_operations.py +1 -7
  21. azure/storage/blob/_generated/operations/_blob_operations.py +21 -47
  22. azure/storage/blob/_generated/operations/_block_blob_operations.py +2 -10
  23. azure/storage/blob/_generated/operations/_container_operations.py +13 -26
  24. azure/storage/blob/_generated/operations/_page_blob_operations.py +3 -14
  25. azure/storage/blob/_generated/operations/_service_operations.py +14 -17
  26. azure/storage/blob/_generated/py.typed +1 -0
  27. azure/storage/blob/_lease.py +52 -63
  28. azure/storage/blob/_list_blobs_helper.py +129 -135
  29. azure/storage/blob/_models.py +480 -277
  30. azure/storage/blob/_quick_query_helper.py +30 -31
  31. azure/storage/blob/_serialize.py +39 -56
  32. azure/storage/blob/_shared/avro/datafile.py +1 -1
  33. azure/storage/blob/_shared/avro/datafile_async.py +1 -1
  34. azure/storage/blob/_shared/base_client.py +3 -1
  35. azure/storage/blob/_shared/base_client_async.py +1 -1
  36. azure/storage/blob/_shared/policies.py +16 -15
  37. azure/storage/blob/_shared/policies_async.py +21 -6
  38. azure/storage/blob/_shared/response_handlers.py +6 -2
  39. azure/storage/blob/_shared/shared_access_signature.py +21 -3
  40. azure/storage/blob/_shared/uploads.py +1 -1
  41. azure/storage/blob/_shared/uploads_async.py +1 -1
  42. azure/storage/blob/_shared_access_signature.py +110 -52
  43. azure/storage/blob/_upload_helpers.py +75 -68
  44. azure/storage/blob/_version.py +1 -1
  45. azure/storage/blob/aio/__init__.py +19 -11
  46. azure/storage/blob/aio/_blob_client_async.py +554 -301
  47. azure/storage/blob/aio/_blob_service_client_async.py +148 -97
  48. azure/storage/blob/aio/_container_client_async.py +289 -140
  49. azure/storage/blob/aio/_download_async.py +485 -337
  50. azure/storage/blob/aio/_lease_async.py +61 -60
  51. azure/storage/blob/aio/_list_blobs_helper.py +94 -96
  52. azure/storage/blob/aio/_models.py +60 -38
  53. azure/storage/blob/aio/_upload_helpers.py +75 -66
  54. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.23.0.dist-info}/METADATA +7 -7
  55. azure_storage_blob-12.23.0.dist-info/RECORD +84 -0
  56. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.23.0.dist-info}/WHEEL +1 -1
  57. azure/storage/blob/_generated/_vendor.py +0 -16
  58. azure_storage_blob-12.21.0b1.dist-info/RECORD +0 -81
  59. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.23.0.dist-info}/LICENSE +0 -0
  60. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.23.0.dist-info}/top_level.txt +0 -0
@@ -8,9 +8,10 @@
8
8
  import functools
9
9
  import warnings
10
10
  from typing import (
11
- Any, Dict, List, Optional, Union,
11
+ Any, cast, Dict, Iterable, List, Optional, Union,
12
12
  TYPE_CHECKING
13
13
  )
14
+ from typing_extensions import Self
14
15
 
15
16
  from azure.core.async_paging import AsyncItemPaged
16
17
  from azure.core.exceptions import HttpResponseError
@@ -18,7 +19,18 @@ from azure.core.pipeline import AsyncPipeline
18
19
  from azure.core.tracing.decorator import distributed_trace
19
20
  from azure.core.tracing.decorator_async import distributed_trace_async
20
21
 
21
-
22
+ from ._blob_client_async import BlobClient
23
+ from ._container_client_async import ContainerClient
24
+ from ._models import ContainerPropertiesPaged, FilteredBlobPaged
25
+ from .._blob_service_client_helpers import _parse_url
26
+ from .._deserialize import service_properties_deserialize, service_stats_deserialize
27
+ from .._encryption import StorageEncryptionMixin
28
+ from .._generated.aio import AzureBlobStorage
29
+ from .._generated.models import StorageServiceProperties, KeyInfo
30
+ from .._models import BlobProperties, ContainerProperties, CorsRule
31
+ from .._serialize import get_api_version
32
+ from .._shared.base_client import parse_query, StorageAccountHostsMixin
33
+ from .._shared.base_client_async import parse_connection_str
22
34
  from .._shared.base_client_async import AsyncStorageAccountHostsMixin, AsyncTransportWrapper
23
35
  from .._shared.response_handlers import (
24
36
  parse_to_internal_user_delegation_key,
@@ -28,34 +40,25 @@ from .._shared.response_handlers import (
28
40
  from .._shared.models import LocationMode
29
41
  from .._shared.parser import _to_utc_datetime
30
42
  from .._shared.policies_async import ExponentialRetry
31
- from .._generated.aio import AzureBlobStorage
32
- from .._generated.models import StorageServiceProperties, KeyInfo
33
- from .._blob_service_client import BlobServiceClient as BlobServiceClientBase
34
- from .._deserialize import service_stats_deserialize, service_properties_deserialize
35
- from .._encryption import StorageEncryptionMixin
36
- from .._models import BlobProperties, ContainerProperties
37
- from .._serialize import get_api_version
38
- from ._blob_client_async import BlobClient
39
- from ._container_client_async import ContainerClient
40
- from ._models import ContainerPropertiesPaged, FilteredBlobPaged
41
43
 
42
44
  if TYPE_CHECKING:
43
45
  from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential
44
46
  from azure.core.credentials_async import AsyncTokenCredential
47
+ from azure.core.pipeline.policies import AsyncHTTPPolicy
45
48
  from datetime import datetime
46
- from .._shared.models import UserDelegationKey
47
49
  from ._lease_async import BlobLeaseClient
48
50
  from .._models import (
49
- PublicAccess,
50
51
  BlobAnalyticsLogging,
52
+ FilteredBlob,
51
53
  Metrics,
52
- CorsRule,
54
+ PublicAccess,
53
55
  RetentionPolicy,
54
- StaticWebsite,
56
+ StaticWebsite
55
57
  )
58
+ from .._shared.models import UserDelegationKey
56
59
 
57
60
 
58
- class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, StorageEncryptionMixin):
61
+ class BlobServiceClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, StorageEncryptionMixin): # type: ignore [misc] # pylint: disable=line-too-long
59
62
  """A client to interact with the Blob Service at the account level.
60
63
 
61
64
  This client provides operations to retrieve and configure the account properties
@@ -119,25 +122,80 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
119
122
  """
120
123
 
121
124
  def __init__(
122
- self, account_url: str,
123
- credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "AsyncTokenCredential"]] = None, # pylint: disable=line-too-long
124
- **kwargs: Any
125
- ) -> None:
125
+ self, account_url: str,
126
+ credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "AsyncTokenCredential"]] = None, # pylint: disable=line-too-long
127
+ **kwargs: Any
128
+ ) -> None:
126
129
  kwargs['retry_policy'] = kwargs.get('retry_policy') or ExponentialRetry(**kwargs)
127
- super(BlobServiceClient, self).__init__(
128
- account_url,
129
- credential=credential,
130
- **kwargs)
130
+ parsed_url, sas_token = _parse_url(account_url=account_url)
131
+ _, sas_token = parse_query(parsed_url.query)
132
+ self._query_str, credential = self._format_query_string(sas_token, credential)
133
+ super(BlobServiceClient, self).__init__(parsed_url, service='blob', credential=credential, **kwargs)
131
134
  self._client = AzureBlobStorage(self.url, base_url=self.url, pipeline=self._pipeline)
132
- self._client._config.version = get_api_version(kwargs) # pylint: disable=protected-access
135
+ self._client._config.version = get_api_version(kwargs) # type: ignore [assignment] # pylint: disable=protected-access
133
136
  self._configure_encryption(kwargs)
134
137
 
138
+ def _format_url(self, hostname):
139
+ """Format the endpoint URL according to the current location
140
+ mode hostname.
141
+
142
+ :param str hostname:
143
+ The hostname of the current location mode.
144
+ :returns: A formatted endpoint URL including current location mode hostname.
145
+ :rtype: str
146
+ """
147
+ return f"{self.scheme}://{hostname}/{self._query_str}"
148
+
149
+ @classmethod
150
+ def from_connection_string(
151
+ cls, conn_str: str,
152
+ credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "AsyncTokenCredential"]] = None, # pylint: disable=line-too-long
153
+ **kwargs: Any
154
+ ) -> Self:
155
+ """Create BlobServiceClient from a Connection String.
156
+
157
+ :param str conn_str:
158
+ A connection string to an Azure Storage account.
159
+ :param credential:
160
+ The credentials with which to authenticate. This is optional if the
161
+ account URL already has a SAS token, or the connection string already has shared
162
+ access key values. The value can be a SAS token string,
163
+ an instance of a AzureSasCredential or AzureNamedKeyCredential from azure.core.credentials,
164
+ an account shared access key, or an instance of a TokenCredentials class from azure.identity.
165
+ Credentials provided here will take precedence over those in the connection string.
166
+ If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
167
+ should be the storage account key.
168
+ :type credential:
169
+ ~azure.core.credentials.AzureNamedKeyCredential or
170
+ ~azure.core.credentials.AzureSasCredential or
171
+ ~azure.core.credentials_async.AsyncTokenCredential or
172
+ str or dict[str, str] or None
173
+ :keyword str audience: The audience to use when requesting tokens for Azure Active Directory
174
+ authentication. Only has an effect when credential is of type TokenCredential. The value could be
175
+ https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
176
+ :returns: A Blob service client.
177
+ :rtype: ~azure.storage.blob.BlobServiceClient
178
+
179
+ .. admonition:: Example:
180
+
181
+ .. literalinclude:: ../samples/blob_samples_authentication.py
182
+ :start-after: [START auth_from_connection_string]
183
+ :end-before: [END auth_from_connection_string]
184
+ :language: python
185
+ :dedent: 8
186
+ :caption: Creating the BlobServiceClient from a connection string.
187
+ """
188
+ account_url, secondary, credential = parse_connection_str(conn_str, credential, 'blob')
189
+ if 'secondary_hostname' not in kwargs:
190
+ kwargs['secondary_hostname'] = secondary
191
+ return cls(account_url, credential=credential, **kwargs)
192
+
135
193
  @distributed_trace_async
136
- async def get_user_delegation_key(self, key_start_time, # type: datetime
137
- key_expiry_time, # type: datetime
138
- **kwargs # type: Any
139
- ):
140
- # type: (...) -> UserDelegationKey
194
+ async def get_user_delegation_key(
195
+ self, key_start_time: "datetime",
196
+ key_expiry_time: "datetime",
197
+ **kwargs: Any
198
+ ) -> "UserDelegationKey":
141
199
  """
142
200
  Obtain a user delegation key for the purpose of signing SAS tokens.
143
201
  A token credential must be present on the service object for this request to succeed.
@@ -151,7 +209,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
151
209
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
152
210
  This value is not tracked or validated on the client. To configure client-side network timesouts
153
211
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
154
- #other-client--per-operation-configuration>`_.
212
+ #other-client--per-operation-configuration>`__.
155
213
  :return: The user delegation key.
156
214
  :rtype: ~azure.storage.blob.UserDelegationKey
157
215
  """
@@ -167,8 +225,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
167
225
  return parse_to_internal_user_delegation_key(user_delegation_key) # type: ignore
168
226
 
169
227
  @distributed_trace_async
170
- async def get_account_information(self, **kwargs):
171
- # type: (Any) -> Dict[str, str]
228
+ async def get_account_information(self, **kwargs: Any) -> Dict[str, str]:
172
229
  """Gets information related to the storage account.
173
230
 
174
231
  The information can also be retrieved if the user has a SAS to a container or blob.
@@ -192,8 +249,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
192
249
  process_storage_error(error)
193
250
 
194
251
  @distributed_trace_async
195
- async def get_service_stats(self, **kwargs):
196
- # type: (Any) -> Dict[str, Any]
252
+ async def get_service_stats(self, **kwargs: Any) -> Dict[str, Any]:
197
253
  """Retrieves statistics related to replication for the Blob service.
198
254
 
199
255
  It is only available when read-access geo-redundant replication is enabled for
@@ -217,7 +273,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
217
273
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
218
274
  This value is not tracked or validated on the client. To configure client-side network timesouts
219
275
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
220
- #other-client--per-operation-configuration>`_.
276
+ #other-client--per-operation-configuration>`__.
221
277
  :return: The blob service stats.
222
278
  :rtype: Dict[str, Any]
223
279
 
@@ -239,8 +295,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
239
295
  process_storage_error(error)
240
296
 
241
297
  @distributed_trace_async
242
- async def get_service_properties(self, **kwargs):
243
- # type: (Any) -> Dict[str, Any]
298
+ async def get_service_properties(self, **kwargs: Any) -> Dict[str, Any]:
244
299
  """Gets the properties of a storage account's Blob service, including
245
300
  Azure Storage Analytics.
246
301
 
@@ -249,7 +304,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
249
304
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
250
305
  This value is not tracked or validated on the client. To configure client-side network timesouts
251
306
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
252
- #other-client--per-operation-configuration>`_.
307
+ #other-client--per-operation-configuration>`__.
253
308
  :returns: An object containing blob service properties such as
254
309
  analytics logging, hour/minute metrics, cors rules, etc.
255
310
  :rtype: Dict[str, Any]
@@ -272,16 +327,15 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
272
327
 
273
328
  @distributed_trace_async
274
329
  async def set_service_properties(
275
- self, analytics_logging=None, # type: Optional[BlobAnalyticsLogging]
276
- hour_metrics=None, # type: Optional[Metrics]
277
- minute_metrics=None, # type: Optional[Metrics]
278
- cors=None, # type: Optional[List[CorsRule]]
279
- target_version=None, # type: Optional[str]
280
- delete_retention_policy=None, # type: Optional[RetentionPolicy]
281
- static_website=None, # type: Optional[StaticWebsite]
282
- **kwargs
283
- ):
284
- # type: (...) -> None
330
+ self, analytics_logging: Optional["BlobAnalyticsLogging"] = None,
331
+ hour_metrics: Optional["Metrics"] = None,
332
+ minute_metrics: Optional["Metrics"] = None,
333
+ cors: Optional[List[CorsRule]] = None,
334
+ target_version: Optional[str] = None,
335
+ delete_retention_policy: Optional["RetentionPolicy"] = None,
336
+ static_website: Optional["StaticWebsite"] = None,
337
+ **kwargs: Any
338
+ ) -> None:
285
339
  """Sets the properties of a storage account's Blob service, including
286
340
  Azure Storage Analytics.
287
341
 
@@ -320,7 +374,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
320
374
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
321
375
  This value is not tracked or validated on the client. To configure client-side network timesouts
322
376
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
323
- #other-client--per-operation-configuration>`_.
377
+ #other-client--per-operation-configuration>`__.
324
378
  :rtype: None
325
379
 
326
380
  .. admonition:: Example:
@@ -341,7 +395,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
341
395
  logging=analytics_logging,
342
396
  hour_metrics=hour_metrics,
343
397
  minute_metrics=minute_metrics,
344
- cors=cors,
398
+ cors=CorsRule._to_generated(cors), # pylint: disable=protected-access
345
399
  default_service_version=target_version,
346
400
  delete_retention_policy=delete_retention_policy,
347
401
  static_website=static_website
@@ -354,11 +408,10 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
354
408
 
355
409
  @distributed_trace
356
410
  def list_containers(
357
- self, name_starts_with=None, # type: Optional[str]
358
- include_metadata=False, # type: Optional[bool]
359
- **kwargs
360
- ):
361
- # type: (...) -> AsyncItemPaged[ContainerProperties]
411
+ self, name_starts_with: Optional[str] = None,
412
+ include_metadata: bool = False,
413
+ **kwargs: Any
414
+ ) -> AsyncItemPaged[ContainerProperties]:
362
415
  """Returns a generator to list the containers under the specified account.
363
416
 
364
417
  The generator will lazily follow the continuation tokens returned by
@@ -385,7 +438,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
385
438
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
386
439
  This value is not tracked or validated on the client. To configure client-side network timesouts
387
440
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
388
- #other-client--per-operation-configuration>`_.
441
+ #other-client--per-operation-configuration>`__.
389
442
  :returns: An iterable (auto-paging) of ContainerProperties.
390
443
  :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.storage.blob.ContainerProperties]
391
444
 
@@ -421,8 +474,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
421
474
  )
422
475
 
423
476
  @distributed_trace
424
- def find_blobs_by_tags(self, filter_expression, **kwargs):
425
- # type: (str, **Any) -> AsyncItemPaged[FilteredBlob]
477
+ def find_blobs_by_tags(self, filter_expression: str, **kwargs: Any) -> AsyncItemPaged["FilteredBlob"]:
426
478
  """The Filter Blobs operation enables callers to list blobs across all
427
479
  containers whose tags match a given search expression. Filter blobs
428
480
  searches across all containers within a storage account but can be
@@ -439,7 +491,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
439
491
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
440
492
  This value is not tracked or validated on the client. To configure client-side network timesouts
441
493
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
442
- #other-client--per-operation-configuration>`_.
494
+ #other-client--per-operation-configuration>`__.
443
495
  :returns: An iterable (auto-paging) response of BlobProperties.
444
496
  :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.storage.blob.FilteredBlob]
445
497
  """
@@ -457,12 +509,11 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
457
509
 
458
510
  @distributed_trace_async
459
511
  async def create_container(
460
- self, name, # type: str
461
- metadata=None, # type: Optional[Dict[str, str]]
462
- public_access=None, # type: Optional[Union[PublicAccess, str]]
463
- **kwargs
464
- ):
465
- # type: (...) -> ContainerClient
512
+ self, name: str,
513
+ metadata: Optional[Dict[str, str]] = None,
514
+ public_access: Optional[Union["PublicAccess", str]] = None,
515
+ **kwargs: Any
516
+ ) -> ContainerClient:
466
517
  """Creates a new container under the specified account.
467
518
 
468
519
  If the container with the same name already exists, a ResourceExistsError will
@@ -489,7 +540,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
489
540
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
490
541
  This value is not tracked or validated on the client. To configure client-side network timesouts
491
542
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
492
- #other-client--per-operation-configuration>`_.
543
+ #other-client--per-operation-configuration>`__.
493
544
  :returns: A container client to interact with the newly created container.
494
545
  :rtype: ~azure.storage.blob.aio.ContainerClient
495
546
 
@@ -551,7 +602,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
551
602
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
552
603
  This value is not tracked or validated on the client. To configure client-side network timesouts
553
604
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
554
- #other-client--per-operation-configuration>`_.
605
+ #other-client--per-operation-configuration>`__.
555
606
  :rtype: None
556
607
 
557
608
  .. admonition:: Example:
@@ -563,17 +614,16 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
563
614
  :dedent: 16
564
615
  :caption: Deleting a container in the blob service.
565
616
  """
566
- container = self.get_container_client(container) # type: ignore
617
+ container_client = self.get_container_client(container)
567
618
  kwargs.setdefault('merge_span', True)
568
619
  timeout = kwargs.pop('timeout', None)
569
- await container.delete_container( # type: ignore
620
+ await container_client.delete_container(
570
621
  lease=lease,
571
622
  timeout=timeout,
572
623
  **kwargs)
573
624
 
574
625
  @distributed_trace_async
575
- async def _rename_container(self, name, new_name, **kwargs):
576
- # type: (str, str, **Any) -> ContainerClient
626
+ async def _rename_container(self, name: str, new_name: str, **kwargs: Any) -> ContainerClient:
577
627
  """Renames a container.
578
628
 
579
629
  Operation is successful only if the source container exists.
@@ -591,14 +641,14 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
591
641
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
592
642
  This value is not tracked or validated on the client. To configure client-side network timesouts
593
643
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
594
- #other-client--per-operation-configuration>`_.
644
+ #other-client--per-operation-configuration>`__.
595
645
  :returns: A container client for the renamed container.
596
646
  :rtype: ~azure.storage.blob.ContainerClient
597
647
  """
598
648
  renamed_container = self.get_container_client(new_name)
599
649
  lease = kwargs.pop('lease', None)
600
650
  try:
601
- kwargs['source_lease_id'] = lease.id # type: str
651
+ kwargs['source_lease_id'] = lease.id
602
652
  except AttributeError:
603
653
  kwargs['source_lease_id'] = lease
604
654
  try:
@@ -608,8 +658,11 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
608
658
  process_storage_error(error)
609
659
 
610
660
  @distributed_trace_async
611
- async def undelete_container(self, deleted_container_name, deleted_container_version, **kwargs):
612
- # type: (str, str, **Any) -> ContainerClient
661
+ async def undelete_container(
662
+ self, deleted_container_name: str,
663
+ deleted_container_version: str,
664
+ **kwargs: Any
665
+ ) -> ContainerClient:
613
666
  """Restores soft-deleted container.
614
667
 
615
668
  Operation will only be successful if used within the specified number of days
@@ -627,7 +680,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
627
680
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
628
681
  This value is not tracked or validated on the client. To configure client-side network timesouts
629
682
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
630
- #other-client--per-operation-configuration>`_.
683
+ #other-client--per-operation-configuration>`__.
631
684
  :returns: The recovered soft-deleted ContainerClient.
632
685
  :rtype: ~azure.storage.blob.aio.ContainerClient
633
686
  """
@@ -643,8 +696,7 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
643
696
  except HttpResponseError as error:
644
697
  process_storage_error(error)
645
698
 
646
- def get_container_client(self, container):
647
- # type: (Union[ContainerProperties, str]) -> ContainerClient
699
+ def get_container_client(self, container: Union[ContainerProperties, str]) -> ContainerClient:
648
700
  """Get a client to interact with the specified container.
649
701
 
650
702
  The container need not already exist.
@@ -665,13 +717,13 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
665
717
  :dedent: 12
666
718
  :caption: Getting the container client to interact with a specific container.
667
719
  """
668
- try:
720
+ if isinstance(container, ContainerProperties):
669
721
  container_name = container.name
670
- except AttributeError:
722
+ else:
671
723
  container_name = container
672
724
  _pipeline = AsyncPipeline(
673
725
  transport=AsyncTransportWrapper(self._pipeline._transport), # pylint: disable = protected-access
674
- policies=self._pipeline._impl_policies # pylint: disable = protected-access
726
+ policies=self._pipeline._impl_policies #type: ignore [arg-type] # pylint: disable = protected-access
675
727
  )
676
728
  return ContainerClient(
677
729
  self.url, container_name=container_name,
@@ -681,11 +733,11 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
681
733
  key_encryption_key=self.key_encryption_key, key_resolver_function=self.key_resolver_function)
682
734
 
683
735
  def get_blob_client(
684
- self, container: Union[ContainerProperties, str],
685
- blob: str,
686
- snapshot: Optional[Union[Dict[str, Any], str]] = None,
687
- *,
688
- version_id: Optional[str] = None
736
+ self, container: Union[ContainerProperties, str],
737
+ blob: str,
738
+ snapshot: Optional[Union[Dict[str, Any], str]] = None,
739
+ *,
740
+ version_id: Optional[str] = None
689
741
  ) -> BlobClient:
690
742
  """Get a client to interact with the specified blob.
691
743
 
@@ -722,20 +774,19 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase, St
722
774
  "Please use 'BlobProperties.name' or any other str input type instead.",
723
775
  DeprecationWarning
724
776
  )
725
- try:
726
- container_name = container.name
727
- except AttributeError:
728
- container_name = container
729
-
730
- try:
731
777
  blob_name = blob.name
732
- except AttributeError:
778
+ else:
733
779
  blob_name = blob
780
+ if isinstance(container, ContainerProperties):
781
+ container_name = container.name
782
+ else:
783
+ container_name = container
734
784
  _pipeline = AsyncPipeline(
735
785
  transport=AsyncTransportWrapper(self._pipeline._transport), # pylint: disable = protected-access
736
- policies=self._pipeline._impl_policies # pylint: disable = protected-access
786
+ policies=cast(Iterable["AsyncHTTPPolicy"],
787
+ self._pipeline._impl_policies) # pylint: disable = protected-access
737
788
  )
738
- return BlobClient( # type: ignore
789
+ return BlobClient(
739
790
  self.url, container_name=container_name, blob_name=blob_name, snapshot=snapshot,
740
791
  credential=self.credential, api_version=self.api_version, _configuration=self._config,
741
792
  _pipeline=_pipeline, _location_mode=self._location_mode, _hosts=self._hosts,