This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new b43fcae14b Simplify conditions on len() in providers/microsoft (#33566)
b43fcae14b is described below

commit b43fcae14bc592017850d172f17a6782082321e8
Author: Miroslav Šedivý <[email protected]>
AuthorDate: Mon Aug 21 08:10:34 2023 +0000

    Simplify conditions on len() in providers/microsoft (#33566)
---
 airflow/providers/microsoft/azure/hooks/cosmos.py | 8 ++++----
 airflow/providers/microsoft/azure/hooks/wasb.py   | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/airflow/providers/microsoft/azure/hooks/cosmos.py 
b/airflow/providers/microsoft/azure/hooks/cosmos.py
index 44a44b7b7e..3a73eeada7 100644
--- a/airflow/providers/microsoft/azure/hooks/cosmos.py
+++ b/airflow/providers/microsoft/azure/hooks/cosmos.py
@@ -153,7 +153,7 @@ class AzureCosmosDBHook(BaseHook):
                 parameters=[json.dumps({"name": "@id", "value": 
collection_name})],
             )
         )
-        if len(existing_container) == 0:
+        if not existing_container:
             return False
 
         return True
@@ -180,7 +180,7 @@ class AzureCosmosDBHook(BaseHook):
         )
 
         # Only create if we did not find it already existing
-        if len(existing_container) == 0:
+        if not existing_container:
             
self.get_conn().get_database_client(self.__get_database_name(database_name)).create_container(
                 collection_name, partition_key=partition_key
             )
@@ -196,7 +196,7 @@ class AzureCosmosDBHook(BaseHook):
                 parameters=[json.dumps({"name": "@id", "value": 
database_name})],
             )
         )
-        if len(existing_database) == 0:
+        if not existing_database:
             return False
 
         return True
@@ -216,7 +216,7 @@ class AzureCosmosDBHook(BaseHook):
         )
 
         # Only create if we did not find it already existing
-        if len(existing_database) == 0:
+        if not existing_database:
             self.get_conn().create_database(database_name)
 
     def delete_database(self, database_name: str) -> None:
diff --git a/airflow/providers/microsoft/azure/hooks/wasb.py 
b/airflow/providers/microsoft/azure/hooks/wasb.py
index 912992afa5..95d4764b67 100644
--- a/airflow/providers/microsoft/azure/hooks/wasb.py
+++ b/airflow/providers/microsoft/azure/hooks/wasb.py
@@ -241,7 +241,7 @@ class WasbHook(BaseHook):
         :return: True if blobs matching the prefix exist, False otherwise.
         """
         blobs = self.get_blobs_list(container_name=container_name, 
prefix=prefix, **kwargs)
-        return len(blobs) > 0
+        return bool(blobs)
 
     def get_blobs_list(
         self,
@@ -502,7 +502,7 @@ class WasbHook(BaseHook):
             blobs_to_delete = [blob_name]
         else:
             blobs_to_delete = []
-        if not ignore_if_missing and len(blobs_to_delete) == 0:
+        if not ignore_if_missing and not blobs_to_delete:
             raise AirflowException(f"Blob(s) not found: {blob_name}")
 
         # The maximum number of blobs that can be deleted in a single request 
is 256 using the underlying
@@ -683,4 +683,4 @@ class WasbAsyncHook(WasbHook):
         :param kwargs: Optional keyword arguments for 
``ContainerClient.walk_blobs``
         """
         blobs = await self.get_blobs_list_async(container_name=container_name, 
prefix=prefix, **kwargs)
-        return len(blobs) > 0
+        return bool(blobs)

Reply via email to