|
7 | 7 |
|
8 | 8 | from azure.core.exceptions import HttpResponseError, IncompleteReadError, ResourceExistsError |
9 | 9 | from azure.storage.blob import BlobServiceClient, ContentSettings |
| 10 | +from collections.abc import Iterable, Sized |
10 | 11 | from rohmu.common.statsd import StatsdConfig |
11 | 12 | from rohmu.errors import ( |
12 | 13 | FileNotFoundFromStorageError, |
|
34 | 35 | ) |
35 | 36 | from rohmu.typing import Metadata |
36 | 37 | from rohmu.util import batched |
37 | | -from typing import Any, BinaryIO, Collection, Iterator, Optional, Tuple, Union |
| 38 | +from typing import Any, BinaryIO, Iterator, Optional, Tuple, Union |
38 | 39 | from typing_extensions import Self |
39 | 40 |
|
40 | 41 | import azure.common |
@@ -317,9 +318,12 @@ def delete_key(self, key: str, preserve_trailing_slash: bool = False) -> None: |
317 | 318 |
|
318 | 319 | return result |
319 | 320 |
|
320 | | - def delete_keys(self, keys: Collection[str], preserve_trailing_slash: bool = False) -> None: |
| 321 | + def delete_keys(self, keys: Iterable[str], preserve_trailing_slash: bool = False) -> None: |
321 | 322 | container_client = self.get_blob_service_client().get_container_client(container=self.container_name) |
322 | | - self.log.debug("Deleting %i keys", len(keys)) |
| 323 | + if isinstance(keys, Sized): |
| 324 | + self.log.debug("Deleting %i keys", len(keys)) |
| 325 | + else: |
| 326 | + self.log.debug("Deleting keys") |
323 | 327 | for keys_batch in batched(keys, 256): # 256 is the maximum batch size for Azure |
324 | 328 | paths_to_delete = [] |
325 | 329 | for key in keys_batch: |
|
0 commit comments