uranusjr commented on a change in pull request #20184:
URL: https://github.com/apache/airflow/pull/20184#discussion_r766219374



##########
File path: airflow/utils/helpers.py
##########
@@ -244,3 +244,18 @@ def build_airflow_url_with_query(query: Dict[str, Any]) -> 
str:
     view = conf.get('webserver', 'dag_default_view').lower()
     url = url_for(f"Airflow.{view}")
     return f"{url}?{parse.urlencode(query)}"
+
+
+def exactly_one(*args):
+    """
+    Returns True if exactly one of *args is "truthy", and False otherwise.
+    :param args:
+    :return:
+    """
+    has_one = False
+    for arg in args:
+        if arg and has_one:
+            return False
+        elif arg:
+            has_one = True
+    return has_one

Review comment:
       That would work. In that case though, I’d make some of the existing 
changes more explicit e.g. `exactly_one(execution_date is not None, run_id is 
not None)` (that’s a bit verbose to me though, so parametrising `exactly_one` 
should still be considered IMO), and document the function in detail so future 
contributors don’t fall in this pitfall. On second thought, this falsy-none 
problem may be an unnecessary pitfall in the first place, indicating we should 
build safeguards in `exactly_one` in the first place.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to