-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix typing of task decorator for retry_condition_fn argument (#16621)
Co-authored-by: nate nowack <[email protected]>
- Loading branch information
1 parent
16e85ce
commit 07b1cab
Showing
2 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/typeddjango/pytest-mypy-plugins/master/pytest_mypy_plugins/schema.json | ||
- case: prefect_task_decorator_no_args | ||
main: | | ||
from prefect import task | ||
@task | ||
def foo(bar: str) -> int: | ||
return 42 | ||
reveal_type(foo) | ||
out: "main:5: note: Revealed type is \"\ | ||
prefect.tasks.Task[[bar: builtins.str], builtins.int]\ | ||
\"" | ||
|
||
- case: prefect_task_decorator_call_with_no_args | ||
main: | | ||
from prefect import task | ||
@task() | ||
def foo(bar: str) -> int: | ||
return 42 | ||
reveal_type(foo) | ||
out: "main:5: note: Revealed type is \"\ | ||
prefect.tasks.Task[[bar: builtins.str], builtins.int]\ | ||
\"" | ||
|
||
- case: prefect_task_decorator_with_name_arg | ||
main: | | ||
from prefect import task | ||
@task(name="bar") | ||
def foo(bar: str) -> int: | ||
return 42 | ||
reveal_type(foo) | ||
out: "main:5: note: Revealed type is \"\ | ||
prefect.tasks.Task[[bar: builtins.str], builtins.int]\ | ||
\"" | ||
|
||
- case: prefect_task_decorator_with_retry_condition_fn_as_none_arg | ||
main: | | ||
from prefect.tasks import task | ||
@task(retry_condition_fn=None) | ||
def foo(bar: str) -> int: | ||
return 42 | ||
reveal_type(foo) | ||
out: "main:5: note: Revealed type is \"\ | ||
prefect.tasks.Task[[bar: builtins.str], builtins.int]\ | ||
\"" | ||
|
||
- case: prefect_task_decorator_with_retry_condition_fn_arg | ||
main: | | ||
from prefect.tasks import P, R, Task, task | ||
from prefect.client.schemas import TaskRun | ||
from prefect.states import State | ||
def retry_condition_fn(task: Task[P, R], task_run: TaskRun, state: State) -> bool: | ||
return False | ||
@task(retry_condition_fn=retry_condition_fn) | ||
def foo(bar: str) -> int: | ||
return 42 | ||
reveal_type(foo) | ||
out: "main:9: note: Revealed type is \"\ | ||
prefect.tasks.Task[[bar: builtins.str], builtins.int]\ | ||
\"" |