ashb commented on a change in pull request #18084:
URL: https://github.com/apache/airflow/pull/18084#discussion_r705206466
##########
File path: airflow/models/xcom.py
##########
@@ -68,12 +80,22 @@ def __repr__(self):
@classmethod
@provide_session
- def set(cls, key, value, execution_date, task_id, dag_id, session=None):
+ def set(cls, key, value, task_id, dag_id, execution_date=None,
run_id=None, session=None):
"""
Store an XCom value.
:return: None
"""
+ if not (execution_date is None) ^ (run_id is None):
+ raise ValueError("Exactly one of execution_date or run_id must be
passed")
Review comment:
There's no convention for this, but I went with ValueError here (but
type error when missing) based on the description in the docs:
> Raised when an operation or function receives an argument that has the
right type but an inappropriate value, and the situation is not described by a
more precise exception such as IndexError.
And this from TypeError docs:
> Passing arguments of the wrong type (e.g. passing a list when an int is
expected) should result in a TypeError, but passing arguments with the wrong
value (e.g. a number outside expected boundaries) should result in a ValueError.
So given those two ValueError felt slightly more appropriate here. WDYT? I
don't really mind either way
--
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]