|
8 | 8 | from functools import partial
|
9 | 9 | from io import BytesIO
|
10 | 10 | from typing import (
|
11 |
| - Any, AnyStr, Dict, IO, Iterable, List, Optional, overload, Tuple, Type, TypeVar, Union, |
| 11 | + Any, AnyStr, Dict, IO, Iterable, List, Optional, overload, Tuple, Union, |
12 | 12 | TYPE_CHECKING
|
13 | 13 | )
|
14 | 14 | from urllib.parse import urlparse, quote, unquote
|
15 | 15 | import warnings
|
16 | 16 |
|
17 | 17 | import six
|
| 18 | +from typing_extensions import Self |
| 19 | + |
18 | 20 | from azure.core.exceptions import ResourceNotFoundError, HttpResponseError, ResourceExistsError
|
19 | 21 | from azure.core.paging import ItemPaged
|
20 | 22 | from azure.core.pipeline import Pipeline
|
21 | 23 | from azure.core.tracing.decorator import distributed_trace
|
22 |
| - |
23 | 24 | from ._shared import encode_base64
|
24 | 25 | from ._shared.base_client import StorageAccountHostsMixin, parse_connection_str, parse_query, TransportWrapper
|
25 | 26 | from ._shared.uploads import IterStreamer
|
|
66 | 67 | )
|
67 | 68 |
|
68 | 69 | if TYPE_CHECKING:
|
| 70 | + from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential, TokenCredential |
69 | 71 | from datetime import datetime
|
70 | 72 | from ._generated.models import BlockList
|
71 | 73 | from ._models import (
|
|
80 | 82 | 'The require_encryption flag is set, but encryption is not supported'
|
81 | 83 | ' for this method.')
|
82 | 84 |
|
83 |
| -ClassType = TypeVar("ClassType") |
84 |
| - |
85 | 85 |
|
86 | 86 | class BlobClient(StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: disable=too-many-public-methods
|
87 | 87 | """A client to interact with a specific blob, although that blob may not yet exist.
|
@@ -149,14 +149,13 @@ class BlobClient(StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: d
|
149 | 149 | :caption: Creating the BlobClient from a SAS URL to a blob.
|
150 | 150 | """
|
151 | 151 | def __init__(
|
152 |
| - self, account_url, # type: str |
153 |
| - container_name, # type: str |
154 |
| - blob_name, # type: str |
155 |
| - snapshot=None, # type: Optional[Union[str, Dict[str, Any]]] |
156 |
| - credential=None, # type: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long |
157 |
| - **kwargs # type: Any |
158 |
| - ): |
159 |
| - # type: (...) -> None |
| 152 | + self, account_url: str, |
| 153 | + container_name: str, |
| 154 | + blob_name: str, |
| 155 | + snapshot: Optional[Union[str, Dict[str, Any]]] = None, |
| 156 | + credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long |
| 157 | + **kwargs: Any |
| 158 | + ) -> None: |
160 | 159 | try:
|
161 | 160 | if not account_url.lower().startswith('http'):
|
162 | 161 | account_url = "https://" + account_url
|
@@ -213,12 +212,11 @@ def _encode_source_url(self, source_url):
|
213 | 212 |
|
214 | 213 | @classmethod
|
215 | 214 | def from_blob_url(
|
216 |
| - cls, # type: Type[ClassType] |
217 |
| - blob_url, # type: str |
218 |
| - credential=None, # type: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long |
219 |
| - snapshot=None, # type: Optional[Union[str, Dict[str, Any]]] |
220 |
| - **kwargs # type: Any |
221 |
| - ): # type: (...) -> ClassType |
| 215 | + cls, blob_url: str, |
| 216 | + credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long |
| 217 | + snapshot: Optional[Union[str, Dict[str, Any]]] = None, |
| 218 | + **kwargs: Any |
| 219 | + ) -> Self: |
222 | 220 | """Create BlobClient from a blob url. This doesn't support customized blob url with '/' in blob name.
|
223 | 221 |
|
224 | 222 | :param str blob_url:
|
@@ -295,14 +293,13 @@ def from_blob_url(
|
295 | 293 |
|
296 | 294 | @classmethod
|
297 | 295 | def from_connection_string(
|
298 |
| - cls, # type: Type[ClassType] |
299 |
| - conn_str, # type: str |
300 |
| - container_name, # type: str |
301 |
| - blob_name, # type: str |
302 |
| - snapshot=None, # type: Optional[str] |
303 |
| - credential=None, # type: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long |
304 |
| - **kwargs # type: Any |
305 |
| - ): # type: (...) -> ClassType |
| 296 | + cls, conn_str: str, |
| 297 | + container_name: str, |
| 298 | + blob_name: str, |
| 299 | + snapshot: Optional[Union[str, Dict[str, Any]]] = None, |
| 300 | + credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long |
| 301 | + **kwargs: Any |
| 302 | + ) -> Self: |
306 | 303 | """Create BlobClient from a Connection String.
|
307 | 304 |
|
308 | 305 | :param str conn_str:
|
|
0 commit comments