This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch v2-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 38b9c7c19b7dadef03f4ef0b6a24baf78273f20c
Author: eladkal <45845474+elad...@users.noreply.github.com>
AuthorDate: Mon May 9 18:17:34 2022 +0300

    Fix `PythonVirtualenvOperator` templated_fields (#23559)
    
    * Fix `PythonVirtualenvOperator` templated_fields
    The `PythonVirtualenvOperator` templated_fields override `PythonOperator` 
templated_fields which caused functionality not to work as expected.
    fixes: https://github.com/apache/airflow/issues/23557
    
    (cherry picked from commit 1657bd2827a3299a91ae0abbbfe4f6b80bd4cdc0)
---
 airflow/operators/python.py    | 3 ++-
 tests/operators/test_python.py | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/airflow/operators/python.py b/airflow/operators/python.py
index 1995992809..920a75d08f 100644
--- a/airflow/operators/python.py
+++ b/airflow/operators/python.py
@@ -327,7 +327,8 @@ class PythonVirtualenvOperator(PythonOperator):
         processing templated fields, for examples ``['.sql', '.hql']``
     """
 
-    template_fields: Sequence[str] = ('requirements',)
+    template_fields: Sequence[str] = tuple({'requirements'} | 
set(PythonOperator.template_fields))
+
     template_ext: Sequence[str] = ('.txt',)
     BASE_SERIALIZABLE_CONTEXT_KEYS = {
         'ds',
diff --git a/tests/operators/test_python.py b/tests/operators/test_python.py
index bf001c0edf..e58b424de6 100644
--- a/tests/operators/test_python.py
+++ b/tests/operators/test_python.py
@@ -868,6 +868,9 @@ class TestPythonVirtualenvOperator(unittest.TestCase):
         task.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE)
         return task
 
+    def test_template_fields(self):
+        assert 
set(PythonOperator.template_fields).issubset(PythonVirtualenvOperator.template_fields)
+
     def test_add_dill(self):
         def f():
             """Ensure dill is correctly installed."""

Reply via email to