uranusjr commented on a change in pull request #22218:
URL: https://github.com/apache/airflow/pull/22218#discussion_r825405206
##########
File path: airflow/models/dag.py
##########
@@ -1278,7 +1278,10 @@ def get_template_env(self) -> jinja2.Environment:
jinja_env_options.update(self.jinja_environment_kwargs)
env: jinja2.Environment
if self.render_template_as_native_obj:
- env = airflow.templates.NativeEnvironment(**jinja_env_options)
+ if force_string:
+ env =
airflow.templates.SandboxedEnvironment(**jinja_env_options)
+ else:
+ env = airflow.templates.NativeEnvironment(**jinja_env_options)
else:
env = airflow.templates.SandboxedEnvironment(**jinja_env_options)
Review comment:
Can be shortened to
```python
use_native_env = self.render_template_as_native_obj and not force_string
if use_native_env:
env = airflow.templates.NativeEnvironment(**jinja_env_options)
else:
env = airflow.templates.SandboxedEnvironment(**jinja_env_options)
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]