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 2022/07/29 20:32:55 UTC
[GitHub] [airflow] Taragolis commented on issue #25409: [Templating]: attributes not defined in `templated_fields` also get value rendered
Taragolis commented on issue #25409:
URL: https://github.com/apache/airflow/issues/25409#issuecomment-1199925757
I think the root of the problem is that Python strings is immutable, but list is mutable.
```python
from copy import copy
class TestOperator(BaseOperator):
template_fields: Sequence[str] = ("inputs", "inputs_one", "inputs_two")
template_ext: Sequence[str] = (".sql",)
def __init__(self, inputs, inputs_one, inputs_two, **base_operator_kwargs):
super().__init__(**base_operator_kwargs)
def __init__(self, inputs, inputs_one, inputs_two, **base_operator_kwargs):
super().__init__(**base_operator_kwargs)
# should render, create shallow copy of original objects
# might required deepcopy, if nested object also mutable.
# from copy import deepcopy
self.inputs = copy(inputs)
self.inputs_one = copy(inputs_one)
self.inputs_two = copy(inputs_two)
# shouldn't render
self.original_inputs_str = inputs
self.original_inputs_one = inputs_one
self.original_inputs_two = inputs_two
```
--
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