ashb commented on a change in pull request #6601: [AIRFLOW-6010] Remove cyclic
imports and pylint disables
URL: https://github.com/apache/airflow/pull/6601#discussion_r348386857
##########
File path: airflow/models/baseoperator.py
##########
@@ -1081,13 +1080,16 @@ def get_extra_links(self, dttm, link_name):
else:
return None
-
-# pylint: disable=protected-access
-BaseOperator._serialized_fields = frozenset(
- vars(BaseOperator(task_id='test')).keys() - {
- 'inlets', 'outlets', '_upstream_task_ids', 'default_args'
- } | {'_task_type', 'subdag', 'ui_color', 'ui_fgcolor', 'template_fields'}
-)
+ @classmethod
+ def get_serialized_fields(cls):
+ """Stringified DAGs and operators contain exactly these fields."""
+ if not cls._serialized_fields:
+ cls._serialized_fields = frozenset(
+ vars(BaseOperator(task_id='test')).keys() - {
Review comment:
I could have sworn I tried this (putting this in the class and couldn't get
it working.) Much nicer!
(Shame that cached_property doesn't work on classes.)
----------------------------------------------------------------
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]
With regards,
Apache Git Services