AetherUnbound commented on a change in pull request #5673: [AIRFLOW-4451] Allow 
templated named tuples
URL: https://github.com/apache/airflow/pull/5673#discussion_r308425938
 
 

 ##########
 File path: airflow/models/baseoperator.py
 ##########
 @@ -646,7 +646,13 @@ def render_template_from_field(self, attr, content, 
context, jinja_env):
         rt = self.render_template
         if isinstance(content, str):
             result = jinja_env.from_string(content).render(**context)
-        elif isinstance(content, (list, tuple)):
+        elif isinstance(content, tuple):
+            if type(content) is not tuple:
+                # Special case for named tuples
+                result = content.__class__(*(rt(attr, e, context) for e in 
content))
+            else:
+                result = (rt(attr, e, context) for e in content)
 
 Review comment:
   Ah, I also need to use a different method for test 52 (since that will never 
be a list)

----------------------------------------------------------------
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

Reply via email to