diff --git a/providers/standard/src/airflow/providers/standard/operators/branch.py b/providers/standard/src/airflow/providers/standard/operators/branch.py index 985a1cb59e1cf..6d670c179cd82 100644 --- a/providers/standard/src/airflow/providers/standard/operators/branch.py +++ b/providers/standard/src/airflow/providers/standard/operators/branch.py @@ -56,9 +56,7 @@ def _expand_task_group_roots( if TYPE_CHECKING: assert dag - if branches_to_execute is None: - return - elif isinstance(branches_to_execute, str) or not isinstance(branches_to_execute, Iterable): + if isinstance(branches_to_execute, str) or not isinstance(branches_to_execute, Iterable): branches_to_execute = [branches_to_execute] for branch in branches_to_execute: diff --git a/providers/standard/src/airflow/providers/standard/sensors/date_time.py b/providers/standard/src/airflow/providers/standard/sensors/date_time.py index 85758210a05f6..17f8aa47f4dfe 100644 --- a/providers/standard/src/airflow/providers/standard/sensors/date_time.py +++ b/providers/standard/src/airflow/providers/standard/sensors/date_time.py @@ -99,8 +99,11 @@ def poke(self, context: Context) -> bool: @property def _moment(self) -> datetime.datetime: - if isinstance(self.target_time, datetime.datetime): - return self.target_time + # Note following is reachable code if Jinja is used for redering template fields and + # render_template_as_native_obj=True is used. + # In this case, the target_time is already a datetime object. + if isinstance(self.target_time, datetime.datetime): # type:ignore[unreachable] + return self.target_time # type:ignore[unreachable] return timezone.parse(self.target_time) diff --git a/providers/standard/src/airflow/providers/standard/utils/python_virtualenv.py b/providers/standard/src/airflow/providers/standard/utils/python_virtualenv.py index 356b6fba75bc1..37ab5bee497ab 100644 --- a/providers/standard/src/airflow/providers/standard/utils/python_virtualenv.py +++ b/providers/standard/src/airflow/providers/standard/utils/python_virtualenv.py @@ -21,7 +21,6 @@ import os import shutil -import sys from pathlib import Path import jinja2 @@ -56,9 +55,7 @@ def _use_uv() -> bool: def _generate_uv_cmd(tmp_dir: str, python_bin: str, system_site_packages: bool) -> list[str]: """Build the command to install the venv via UV.""" - cmd = ["uv", "venv", "--allow-existing", "--seed"] - if python_bin is not None: - cmd += ["--python", python_bin] + cmd = ["uv", "venv", "--allow-existing", "--seed", "--python", python_bin] if system_site_packages: cmd.append("--system-site-packages") cmd.append(tmp_dir) @@ -67,8 +64,6 @@ def _generate_uv_cmd(tmp_dir: str, python_bin: str, system_site_packages: bool) def _generate_venv_cmd(tmp_dir: str, python_bin: str, system_site_packages: bool) -> list[str]: """We are using venv command instead of venv module to allow creation of venv for different python versions.""" - if python_bin is None: - python_bin = sys.executable cmd = [python_bin, "-m", "venv", tmp_dir] if system_site_packages: cmd.append("--system-site-packages") diff --git a/providers/standard/tests/unit/standard/operators/test_python.py b/providers/standard/tests/unit/standard/operators/test_python.py index 7a166559a72a5..7a3ad2167a964 100644 --- a/providers/standard/tests/unit/standard/operators/test_python.py +++ b/providers/standard/tests/unit/standard/operators/test_python.py @@ -1743,6 +1743,24 @@ def setup_tests(self): self.branch_1 = EmptyOperator(task_id="branch_1") self.branch_2 = EmptyOperator(task_id="branch_2") + # Skip some tests from base class that are not applicable for branching operators + # as the branching condition is mandatory but not given by base class + @pytest.mark.skip(reason="Test is not working for branching operators") + def test_string_args(self): + pass + + @pytest.mark.skip(reason="Test is not working for branching operators") + def test_return_none(self): + pass + + @pytest.mark.skip(reason="Test is not working for branching operators") + def test_nonimported_as_arg(self): + pass + + @pytest.mark.skip(reason="Test is not working for branching operators") + def test_on_skip_exit_code(self): + pass + def test_with_args(self): def f(a, b, c=False, d=False): if a == 0 and b == 1 and c and not d: