9
9
import re
10
10
import time
11
11
import urllib .parse
12
- from typing import TYPE_CHECKING , Any , Dict , List , Mapping , Optional , Sequence , Tuple
12
+ from typing import TYPE_CHECKING , Any , Mapping , Sequence
13
13
14
14
from .xml import etree
15
15
25
25
SHARED_KEY = "shared_key"
26
26
27
27
28
- def load_credentials () -> Dict [str , Any ]:
28
+ def load_credentials () -> dict [str , Any ]:
29
29
# When AZURE_USE_IDENTITY=1, boostedblob will use the azure-identity package to retrieve AAD access tokens
30
30
if os .getenv ("AZURE_USE_IDENTITY" , "0" ) == "1" :
31
31
return {"_azure_auth" : "azure-identity" }
@@ -127,7 +127,7 @@ def load_credentials() -> Dict[str, Any]:
127
127
)
128
128
129
129
130
- def load_stored_subscription_ids () -> List [str ]:
130
+ def load_stored_subscription_ids () -> list [str ]:
131
131
"""Return a list of subscription ids from the local azure profile.
132
132
133
133
The default subscription will appear first in the list.
@@ -146,7 +146,7 @@ def load_stored_subscription_ids() -> List[str]:
146
146
return [sub ["id" ] for sub in subscriptions ]
147
147
148
148
149
- async def get_access_token (cache_key : Tuple [str , Optional [ str ]] ) -> Tuple [Any , float ]:
149
+ async def get_access_token (cache_key : tuple [str , str | None ] ) -> tuple [Any , float ]:
150
150
account , container = cache_key
151
151
now = time .time ()
152
152
creds = load_credentials ()
@@ -263,7 +263,7 @@ async def get_access_token(cache_key: Tuple[str, Optional[str]]) -> Tuple[Any, f
263
263
)
264
264
265
265
266
- async def can_access_account (account : str , container : Optional [ str ] , auth : Tuple [str , str ]) -> bool :
266
+ async def can_access_account (account : str , container : str | None , auth : tuple [str , str ]) -> bool :
267
267
from .request import Request , azure_auth_req
268
268
269
269
if not container :
@@ -343,8 +343,8 @@ def create_access_token_request(
343
343
344
344
345
345
async def get_storage_account_id_with_subscription (
346
- subscription_id : str , account : str , auth : Tuple [str , str ]
347
- ) -> Optional [ str ] :
346
+ subscription_id : str , account : str , auth : tuple [str , str ]
347
+ ) -> str | None :
348
348
from .request import Request , azure_auth_req
349
349
350
350
req = Request (
@@ -393,7 +393,7 @@ async def get_storage_account_id_with_subscription(
393
393
return None
394
394
395
395
396
- async def get_storage_account_id (account : str , auth : Tuple [str , str ]) -> Optional [ str ] :
396
+ async def get_storage_account_id (account : str , auth : tuple [str , str ]) -> str | None :
397
397
from .request import Request , azure_auth_req
398
398
399
399
stored_subscription_ids = load_stored_subscription_ids ()
@@ -432,8 +432,8 @@ async def get_storage_account_id(account: str, auth: Tuple[str, str]) -> Optiona
432
432
433
433
434
434
async def get_storage_account_key (
435
- account : str , creds : Mapping [str , Any ], container_hint : Optional [ str ] = None
436
- ) -> Optional [ Tuple [ Any , float ]] :
435
+ account : str , creds : Mapping [str , Any ], container_hint : str | None = None
436
+ ) -> tuple [ Any , float ] | None :
437
437
from .request import Request , azure_auth_req
438
438
439
439
# get an access token for the management service
@@ -524,7 +524,7 @@ def canonicalized_headers() -> str:
524
524
return f"SharedKey { storage_account } :{ signature } "
525
525
526
526
527
- async def get_sas_token (cache_key : Tuple [str , Optional [ str ]] ) -> Tuple [Any , float ]:
527
+ async def get_sas_token (cache_key : tuple [str , str | None ] ) -> tuple [Any , float ]:
528
528
from .globals import config
529
529
from .request import Request , azure_auth_req
530
530
@@ -573,7 +573,7 @@ async def get_sas_token(cache_key: Tuple[str, Optional[str]]) -> Tuple[Any, floa
573
573
return user_delegation_key , time .time () + AZURE_SAS_TOKEN_EXPIRATION_SECONDS
574
574
575
575
576
- async def generate_signed_url (path : AzurePath ) -> Tuple [str , datetime .datetime ]:
576
+ async def generate_signed_url (path : AzurePath ) -> tuple [str , datetime .datetime ]:
577
577
# https://docs.microsoft.com/en-us/rest/api/storageservices/delegate-access-with-shared-access-signature
578
578
# https://docs.microsoft.com/en-us/rest/api/storageservices/create-user-delegation-sas
579
579
# https://docs.microsoft.com/en-us/rest/api/storageservices/service-sas-examples
0 commit comments