malthe commented on a change in pull request #18112:
URL: https://github.com/apache/airflow/pull/18112#discussion_r705624641
##########
File path: airflow/exceptions.py
##########
@@ -256,12 +278,21 @@ def __init__(
self.method_name = method_name
self.kwargs = kwargs
self.timeout = timeout
+
# Check timeout type at runtime
if self.timeout is not None and not hasattr(self.timeout,
"total_seconds"):
raise ValueError("Timeout value must be a timedelta")
+ # Check keyword arguments
+ if kwargs:
+ if method_name is None:
+ raise ValueError("Keyword arguments not allowed when method is
not specified")
Review comment:
@andrewgodwin note that the operator should not set a `pre_execute` hook
on itself, that would be weird I think due to the semantics around
`pre_execute` – it runs sequentially just before `execute` so you could just
put that logic into the `execute` method.
The idea with `pre_execute` is that a user can have some custom logic before
the operator executes. They could subclass and come up with some name for the
class, but this is a simple way to change the execution flow on an ad-hoc basis.
--
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]