You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/07/04 07:13:20 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #24787: Helper exactly_one should treat NOTSET as None

uranusjr commented on code in PR #24787:
URL: https://github.com/apache/airflow/pull/24787#discussion_r912692169


##########
airflow/utils/helpers.py:
##########
@@ -311,7 +312,14 @@ def exactly_one(*args) -> bool:
         raise ValueError(
             "Not supported for iterable args. Use `*` to unpack your iterable in the function call."
         )
-    return sum(map(bool, args)) == 1
+
+    def is_set(val):
+        if isinstance(val, ArgNotSet):
+            return False
+        else:
+            return bool(val)
+
+    return sum(map(is_set, args)) == 1

Review Comment:
   ```suggestion
       return sum(a is not NOT_SET and bool(a) for a in args) == 1
   ```
   
   Does this read better?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org