You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/07/29 16:43:22 UTC
[GitHub] [airflow] ashb commented on a change in pull request #5673:
[AIRFLOW-4451] Allow templated named tuples
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:
users@infra.apache.org
With regards,
Apache Git Services