From 024def1fdf50f291876c461c0f1c81dedf94da5a Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 24 Feb 2025 03:58:08 -0500 Subject: [PATCH 1/3] Blob --- .../azure/storage/blob/_shared/avro/avro_io.py | 4 ++-- .../azure/storage/blob/_shared/avro/avro_io_async.py | 2 +- .../azure/storage/blob/_shared/policies_async.py | 2 +- .../azure/storage/blob/_shared/request_handlers.py | 3 +-- .../azure/storage/blob/_shared/uploads_async.py | 5 ++--- .../azure/storage/blob/aio/_download_async.py | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/avro/avro_io.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/avro/avro_io.py index 3e46f1fb53f..7b59165b60d 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/avro/avro_io.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/avro/avro_io.py @@ -162,11 +162,11 @@ def read_utf8(self): try: return input_bytes.decode('utf-8') except UnicodeDecodeError as exn: - logger.error('Invalid UTF-8 input bytes: %r', input_bytes) + logger.error('Invalid UTF-8 input bytes: %r', input_bytes) # pylint: disable=do-not-log-raised-errors raise exn else: # PY2 - return unicode(input_bytes, "utf-8") # pylint: disable=undefined-variable + return unicode(input_bytes, "utf-8") # pylint: disable=undefined-variable def skip_null(self): pass diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/avro/avro_io_async.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/avro/avro_io_async.py index 8688661b5ad..487f5e4b47b 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/avro/avro_io_async.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/avro/avro_io_async.py @@ -145,7 +145,7 @@ async def read_utf8(self): try: return input_bytes.decode('utf-8') except UnicodeDecodeError as exn: - logger.error('Invalid UTF-8 input bytes: %r', input_bytes) + logger.error('Invalid UTF-8 input bytes: %r', input_bytes) # pylint: disable=do-not-log-raised-errors raise exn else: # PY2 diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/policies_async.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/policies_async.py index 86a4b4c05f3..c44e19ca06e 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/policies_async.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/policies_async.py @@ -5,7 +5,7 @@ # -------------------------------------------------------------------------- # pylint: disable=invalid-overridden-method -import asyncio +import asyncio # pylint: disable=do-not-import-asyncio import logging import random from typing import Any, Dict, TYPE_CHECKING diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/request_handlers.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/request_handlers.py index 54927cc7397..af500c8727f 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/request_handlers.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/request_handlers.py @@ -136,8 +136,7 @@ def validate_and_format_range_headers( return range_header, range_validation -def add_metadata_headers(metadata=None): - # type: (Optional[Dict[str, str]]) -> Dict[str, str] +def add_metadata_headers(metadata: Optional[Dict[str, str]] = None) -> Dict[str, str]: headers = {} if metadata: for key, value in metadata.items(): diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/uploads_async.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/uploads_async.py index 3e102ec5dae..a056cd29023 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/uploads_async.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/uploads_async.py @@ -4,10 +4,9 @@ # license information. # -------------------------------------------------------------------------- -import asyncio +import asyncio # pylint: disable=do-not-import-asyncio import inspect import threading -from asyncio import Lock from io import UnsupportedOperation from itertools import islice from math import ceil @@ -165,7 +164,7 @@ def __init__( # Progress feedback self.progress_total = 0 - self.progress_lock = Lock() if parallel else None + self.progress_lock = asyncio.Lock() if parallel else None self.progress_hook = progress_hook # Encryption diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_download_async.py b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_download_async.py index 4676c2e6675..8a929647e78 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_download_async.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_download_async.py @@ -6,7 +6,7 @@ # pylint: disable=invalid-overridden-method # mypy: disable-error-code=override -import asyncio +import asyncio # pylint: disable=do-not-import-asyncio import codecs import sys import warnings From 73db550a1c03467dd6cb46fa88b12e51ec1ba274 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 24 Feb 2025 04:04:25 -0500 Subject: [PATCH 2/3] File share --- .../azure/storage/fileshare/_shared/policies_async.py | 2 +- .../azure/storage/fileshare/_shared/request_handlers.py | 3 +-- .../azure/storage/fileshare/_shared/uploads_async.py | 5 ++--- .../azure/storage/fileshare/aio/_download_async.py | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/policies_async.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/policies_async.py index 1c030a828cd..807a51dd297 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/policies_async.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/policies_async.py @@ -5,7 +5,7 @@ # -------------------------------------------------------------------------- # pylint: disable=invalid-overridden-method -import asyncio +import asyncio # pylint: disable=do-not-import-asyncio import logging import random from typing import Any, Dict, TYPE_CHECKING diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/request_handlers.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/request_handlers.py index 54927cc7397..af500c8727f 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/request_handlers.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/request_handlers.py @@ -136,8 +136,7 @@ def validate_and_format_range_headers( return range_header, range_validation -def add_metadata_headers(metadata=None): - # type: (Optional[Dict[str, str]]) -> Dict[str, str] +def add_metadata_headers(metadata: Optional[Dict[str, str]] = None) -> Dict[str, str]: headers = {} if metadata: for key, value in metadata.items(): diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/uploads_async.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/uploads_async.py index 3e102ec5dae..a056cd29023 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/uploads_async.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/uploads_async.py @@ -4,10 +4,9 @@ # license information. # -------------------------------------------------------------------------- -import asyncio +import asyncio # pylint: disable=do-not-import-asyncio import inspect import threading -from asyncio import Lock from io import UnsupportedOperation from itertools import islice from math import ceil @@ -165,7 +164,7 @@ def __init__( # Progress feedback self.progress_total = 0 - self.progress_lock = Lock() if parallel else None + self.progress_lock = asyncio.Lock() if parallel else None self.progress_hook = progress_hook # Encryption diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_download_async.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_download_async.py index 278c5e01d64..44b45084a67 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_download_async.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_download_async.py @@ -6,7 +6,7 @@ # pylint: disable=invalid-overridden-method # mypy: disable-error-code=override -import asyncio +import asyncio # pylint: disable=do-not-import-asyncio import sys import warnings from io import BytesIO From bbee5fa0ebc6d09163da2393518e221de7f90baf Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 24 Feb 2025 04:09:57 -0500 Subject: [PATCH 3/3] Queue --- .../azure-storage-queue/azure/storage/queue/_serialize.py | 5 ++--- .../azure/storage/queue/_shared/policies_async.py | 2 +- .../azure/storage/queue/_shared/request_handlers.py | 3 +-- .../azure/storage/queue/_shared/uploads_async.py | 5 ++--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_serialize.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_serialize.py index 91b518280fe..21199c3d543 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_serialize.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_serialize.py @@ -3,7 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from typing import (Any, Dict) +from typing import Any, Dict _SUPPORTED_API_VERSIONS = [ '2019-02-02', @@ -31,8 +31,7 @@ ] -def get_api_version(kwargs): - # type: (Dict[str, Any]) -> str +def get_api_version(kwargs: Dict[str, Any]) -> str: api_version = kwargs.get('api_version', None) if api_version and api_version not in _SUPPORTED_API_VERSIONS: versions = '\n'.join(_SUPPORTED_API_VERSIONS) diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/policies_async.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/policies_async.py index 1c030a828cd..807a51dd297 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/policies_async.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/policies_async.py @@ -5,7 +5,7 @@ # -------------------------------------------------------------------------- # pylint: disable=invalid-overridden-method -import asyncio +import asyncio # pylint: disable=do-not-import-asyncio import logging import random from typing import Any, Dict, TYPE_CHECKING diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/request_handlers.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/request_handlers.py index 54927cc7397..af500c8727f 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/request_handlers.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/request_handlers.py @@ -136,8 +136,7 @@ def validate_and_format_range_headers( return range_header, range_validation -def add_metadata_headers(metadata=None): - # type: (Optional[Dict[str, str]]) -> Dict[str, str] +def add_metadata_headers(metadata: Optional[Dict[str, str]] = None) -> Dict[str, str]: headers = {} if metadata: for key, value in metadata.items(): diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/uploads_async.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/uploads_async.py index 3e102ec5dae..a056cd29023 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/uploads_async.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/uploads_async.py @@ -4,10 +4,9 @@ # license information. # -------------------------------------------------------------------------- -import asyncio +import asyncio # pylint: disable=do-not-import-asyncio import inspect import threading -from asyncio import Lock from io import UnsupportedOperation from itertools import islice from math import ceil @@ -165,7 +164,7 @@ def __init__( # Progress feedback self.progress_total = 0 - self.progress_lock = Lock() if parallel else None + self.progress_lock = asyncio.Lock() if parallel else None self.progress_hook = progress_hook # Encryption