Skip to content

Commit

Permalink
Merge branch 'main' into defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
jlowin authored Sep 6, 2024
2 parents 4e6e6b8 + fe7e638 commit 32d8549
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/controlflow/tasks/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ async def run_async(

@contextmanager
def create_context(self):
stack = ctx.get("tasks", [])
stack = ctx.get("tasks") or []
with ctx(tasks=stack + [self]):
yield self

Expand Down
2 changes: 1 addition & 1 deletion src/controlflow/utilities/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __call__(self, **kwargs: Any) -> Generator[None, None, Any]:
ctx = ScopedContext(
dict(
flow=None,
tasks=[],
tasks=None,
agent=None,
orchestrator=None,
tui=None,
Expand Down
6 changes: 3 additions & 3 deletions tests/flows/test_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class TestFlowContext:
def test_flow_context_manager(self):
with Flow() as flow:
assert ctx.get("flow") == flow
assert ctx.get("tasks") == []
assert ctx.get("tasks") is None
assert ctx.get("flow") is None
assert ctx.get("tasks") == []
assert ctx.get("tasks") is None

def test_get_flow_within_context(self):
with Flow() as flow:
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_flow_context_resets_task_tracking(self):
nested_task = Task("Nested task")
assert nested_task.parent is None
assert ctx.get("tasks") == [parent_task]
assert ctx.get("tasks") == []
assert ctx.get("tasks") is None


class TestFlowHistory:
Expand Down
4 changes: 2 additions & 2 deletions tests/tasks/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def test_status_coverage():


def test_context_open_and_close():
assert ctx.get("tasks") == []
assert ctx.get("tasks") is None
with SimpleTask() as ta:
assert ctx.get("tasks") == [ta]
with SimpleTask() as tb:
assert ctx.get("tasks") == [ta, tb]
assert ctx.get("tasks") == [ta]
assert ctx.get("tasks") == []
assert ctx.get("tasks") is None


def test_task_requires_objective():
Expand Down

0 comments on commit 32d8549

Please sign in to comment.