diff --git a/airflow/operators/python.py b/airflow/operators/python.py index 1995992809f57..920a75d08f766 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 bf001c0edf641..e58b424de6453 100644 --- a/tests/operators/test_python.py +++ b/tests/operators/test_python.py @@ -868,6 +868,9 @@ def _run_as_operator(self, fn, python_version=sys.version_info[0], **kwargs): 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."""