You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "uranusjr (via GitHub)" <gi...@apache.org> on 2023/11/06 03:13:40 UTC

Re: [PR] Add LiteralValue wrapper rendered without templating [airflow]

uranusjr commented on code in PR #35017:
URL: https://github.com/apache/airflow/pull/35017#discussion_r1382744257


##########
airflow/template/templater.py:
##########
@@ -155,6 +167,8 @@ def render_template(
             return self._render(template, context)
         if isinstance(value, ResolveMixin):
             return value.resolve(context)
+        if isinstance(value, LiteralValue):
+            return value.value

Review Comment:
   Instead of adding a special case, it may be better to make LiteralValue inherit ResolveMixin and implement `resolve` to just return `value`. This would avoid surprises if the resolution logic is used elsewhere (can’t think of one but you never know with a large code base).



##########
airflow/template/templater.py:
##########
@@ -155,6 +167,8 @@ def render_template(
             return self._render(template, context)
         if isinstance(value, ResolveMixin):
             return value.resolve(context)
+        if isinstance(value, LiteralValue):
+            return value.value

Review Comment:
   Instead of adding a special case, it may be better to make LiteralValue inherit ResolveMixin and implement `resolve` to just return `value`. This would avoid surprises if the resolution logic is used elsewhere (can’t think of one but you never know with a large code base).



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org