turbaszek commented on a change in pull request #8805:
URL: https://github.com/apache/airflow/pull/8805#discussion_r422651378
##########
File path: airflow/models/baseoperator.py
##########
@@ -60,9 +60,25 @@
ScheduleInterval = Union[str, timedelta, relativedelta]
+class BaseOperatorMeta(type):
+ """
+ Base metaclass of BaseOperator.
+ """
+ def __call__(cls, *args, **kwargs):
+ """
+ Called when you call BaseOperator(). In this way we are able to
perform an action
+ after initializing an operator no matter where the
``super().__init__`` is called
+ (before or after assign of new attributes in a custom operator).
+ """
+ obj = type.__call__(cls, *args, **kwargs)
+ # Set upstream task defined by XComArgs passed to template fields of
an operator
+ obj._set_xcomargs_dependencies() # pylint: disable=protected-access
Review comment:
Additionally, I think we will have to introduce this metaclass now or
later. Here's @mik-laj PR where he tried to address the `@apply_defaults`:
https://github.com/apache/airflow/pull/7450
One of the reasons to do that (from [devlist
thread](https://lists.apache.org/thread.html/r4cf535e5dec1fbf8330f3c86031519092ca4820b382d3738413b23cd%40%3Cdev.airflow.apache.org%3E)):
> I saw that PR today and it made me realize I've not been using
apply_defaults in much of my code! Look forward to this being an automaic
operation via a MetaClass, great work :)
However, this point is very valid:
> meta_class introduce backward compatibility problems for users who already
have metaclass defined for their operator ( they will have to inherit from
BaseOperatorMeta)
I suppose that we can add some refactor step once we have 2.0 and
https://github.com/apache/airflow/issues/8765
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]