|
5 | 5 |
|
6 | 6 | from pydantic import BaseModel |
7 | 7 |
|
8 | | -from sheppy import Depends, Task, task |
| 8 | +from sheppy import CURRENT_TASK, Depends, Task, task |
9 | 9 |
|
10 | 10 |
|
11 | 11 | class User(BaseModel): |
@@ -139,18 +139,18 @@ async def async_task_with_pydantic_model(user: User) -> Status: |
139 | 139 |
|
140 | 140 |
|
141 | 141 | @task |
142 | | -def task_with_self(self: Task, x: int, y: int) -> dict[str, Any]: |
143 | | - return {"task_id": self.id, "result": x + y} |
| 142 | +def task_with_current_task(current: Task = CURRENT_TASK, x: int = 5, y: int = 6) -> dict[str, Any]: |
| 143 | + return {"task_id": current.id, "result": x + y} |
144 | 144 |
|
145 | 145 |
|
146 | 146 | @task |
147 | | -def task_with_self_middle(x: int, self: Task, y: int) -> dict[str, Any]: |
148 | | - return {"task_id": self.id, "result": x + y} |
| 147 | +def task_with_current_task_middle(x: int, current: Task = CURRENT_TASK, y: int = 7) -> dict[str, Any]: |
| 148 | + return {"task_id": current.id, "result": x + y} |
149 | 149 |
|
150 | 150 |
|
151 | 151 | @task |
152 | | -def task_with_self_end(x: int, y: int, self: Task) -> dict[str, Any]: |
153 | | - return {"task_id": self.id, "result": x + y} |
| 152 | +def task_with_current_task_end(x: int, y: int, current: Task = CURRENT_TASK) -> dict[str, Any]: |
| 153 | + return {"task_id": current.id, "result": x + y} |
154 | 154 |
|
155 | 155 |
|
156 | 156 | @task |
@@ -482,9 +482,9 @@ def deep_recursion_tasks() -> list[TaskTestCase]: |
482 | 482 | def self_referencing_tasks() -> list[TaskTestCase]: |
483 | 483 | """Tasks that should fail.""" |
484 | 484 | return [ |
485 | | - TaskTestCase("task_with_self", task_with_self, (22, 33), expected_result=55), |
486 | | - TaskTestCase("task_with_self_middle", task_with_self_middle, (22, 33), expected_result=55), |
487 | | - TaskTestCase("task_with_self_end", task_with_self_end, (22, 33), expected_result=55), |
| 485 | + TaskTestCase("task_with_current_task", task_with_current_task, (), {"x": 22, "y": 33}, expected_result=55), |
| 486 | + TaskTestCase("task_with_current_task_middle", task_with_current_task_middle, (22, ), {"y": 33}, expected_result=55), |
| 487 | + TaskTestCase("task_with_current_task_end", task_with_current_task_end, (22, 33), expected_result=55), |
488 | 488 | ] |
489 | 489 |
|
490 | 490 | @staticmethod |
|
0 commit comments