Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import os
import shutil
import sys
from pathlib import Path

import jinja2
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand Down
18 changes: 18 additions & 0 deletions providers/standard/tests/unit/standard/operators/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down