Skip to content

Commit c869fa4

Browse files
committed
Update return types for task_with_context decorator
1 parent 70e2591 commit c869fa4

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

python/fluxqueue/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,16 @@ async def create_user_task(ctx: DbContext, email: str, username: str):
169169
"""
170170

171171
@overload
172-
def decorator(func: Callable[Concatenate[C, P], None]) -> Callable[P, None]: ...
172+
def decorator(func: Callable[Concatenate[C, P], None]) -> Task[P, None]: ...
173173

174174
@overload
175175
def decorator(
176176
func: Callable[Concatenate[C, P], Coroutine[Any, Any, None]],
177-
) -> Callable[P, Coroutine[Any, Any, None]]: ...
177+
) -> Task[P, Coroutine[Any, Any, None]]: ...
178178

179179
def decorator(
180180
func: Callable[Concatenate[C, P], None | Coroutine[Any, Any, None]],
181-
) -> Callable[P, None | Coroutine[Any, Any, None]]:
181+
) -> Task[P, None | Coroutine[Any, Any, None]]:
182182
return _with_context(
183183
cast(Any, func),
184184
name=name,

tests/test_schedule.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from fluxqueue import Context
2+
13
from .conftest import TestEnvFixture
24

35

@@ -8,3 +10,10 @@ def task():
810

911
assert hasattr(task, "defer")
1012
assert hasattr(task, "cron")
13+
14+
@test_env.fluxqueue.task_with_context()
15+
def task_with_ctx(ctx: Context):
16+
pass
17+
18+
assert hasattr(task_with_ctx, "defer")
19+
assert hasattr(task_with_ctx, "cron")

0 commit comments

Comments
 (0)