From 216d7f5e42cab6ee3646666c0694d2cc3ab4ab36 Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Wed, 12 Jul 2023 08:41:15 +0200 Subject: [PATCH] Fix get_blobs_list_async method to return BlobProperties The get_blobs_list_async method advertised to return list of BlobProperties but returned list of blob names. This is a bug that has been detected by MyPy checks with the new Azure blob package. --- airflow/providers/microsoft/azure/CHANGELOG.rst | 10 ++++++++++ airflow/providers/microsoft/azure/hooks/wasb.py | 4 ++-- airflow/providers/microsoft/azure/provider.yaml | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/airflow/providers/microsoft/azure/CHANGELOG.rst b/airflow/providers/microsoft/azure/CHANGELOG.rst index df78b4e7a88b..b05f1c931014 100644 --- a/airflow/providers/microsoft/azure/CHANGELOG.rst +++ b/airflow/providers/microsoft/azure/CHANGELOG.rst @@ -27,6 +27,16 @@ Changelog --------- +6.2.1 +..... + +.. note:: + Note: this version contains a fix to ``get_blobs_list_async`` method in ``WasbHook`` where it returned + a list of blob names, but advertised (via type hints) that it returns a list of ``BlobProperties`` objects. + This was a bug in the implementation and it was fixed in this release. However, if you were relying on the + previous behaviour, you might need to retrieve ``name`` property from the array elements returned by + this method. + 6.2.0 ..... diff --git a/airflow/providers/microsoft/azure/hooks/wasb.py b/airflow/providers/microsoft/azure/hooks/wasb.py index 794da8dd8575..2281e184c22b 100644 --- a/airflow/providers/microsoft/azure/hooks/wasb.py +++ b/airflow/providers/microsoft/azure/hooks/wasb.py @@ -687,10 +687,10 @@ async def get_blobs_list_async( :param delimiter: filters objects based on the delimiter (for e.g '.csv') """ container = self._get_container_client(container_name) - blob_list = [] + blob_list: list[BlobProperties] = [] blobs = container.walk_blobs(name_starts_with=prefix, include=include, delimiter=delimiter, **kwargs) async for blob in blobs: - blob_list.append(blob.name) + blob_list.append(blob) return blob_list async def check_for_prefix_async(self, container_name: str, prefix: str, **kwargs: Any) -> bool: diff --git a/airflow/providers/microsoft/azure/provider.yaml b/airflow/providers/microsoft/azure/provider.yaml index 441f51a5786b..a12088220485 100644 --- a/airflow/providers/microsoft/azure/provider.yaml +++ b/airflow/providers/microsoft/azure/provider.yaml @@ -22,6 +22,7 @@ description: | `Microsoft Azure `__ suspended: false versions: + - 6.2.1 - 6.2.0 - 6.1.2 - 6.1.1