ashb commented on a change in pull request #5673: [AIRFLOW-4451] Allow
templated named tuples
URL: https://github.com/apache/airflow/pull/5673#discussion_r308328529
##########
File path: airflow/models/baseoperator.py
##########
@@ -646,6 +646,12 @@ 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, 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)
elif isinstance(content, (list, tuple)):
Review comment:
```suggestion
elif isinstance(content, list):
```
It can't be a tuple anymore - that is handled by the previous elif you've
just added
----------------------------------------------------------------
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