Skip to content

Commit

Permalink
Fix PythonVirtualenvOperator templated_fields (apache#23559)
Browse files Browse the repository at this point in the history
* Fix `PythonVirtualenvOperator` templated_fields
The `PythonVirtualenvOperator` templated_fields override `PythonOperator` templated_fields which caused functionality not to work as expected.
fixes: apache#23557
  • Loading branch information
eladkal authored May 9, 2022
1 parent 7132be2 commit 1657bd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion airflow/operators/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 3 additions & 0 deletions tests/operators/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit 1657bd2

Please sign in to comment.