elegant-australia-91422
01/17/2023, 6:27 AMtall-lock-23197
elegant-australia-91422
01/17/2023, 1:53 PMelegant-australia-91422
01/17/2023, 2:50 PMelegant-australia-91422
01/17/2023, 5:18 PMthankful-minister-83577
thankful-minister-83577
elegant-australia-91422
01/17/2023, 5:36 PM@task
& @task()
are both valid usages is where the trickiness comes in I believe. If we'd be willing to relax that and enforce @task()
as the correct usage, I think this is achievable
Also not sure about the best way to wire the `P.args`/`P.kwargs` stuff into PythonFunctionTask
(PythonFunctionTask
itself doesn't even appear to be callable/I think there are some other things that aren't quite right in the typing)elegant-australia-91422
01/17/2023, 5:37 PMfrom flytekit.core.task import task
from flytekit.core.workflow import workflow
@task()
def test_task(a: int, b: float) -> float:
return a + b
@workflow()
def test_wf() -> float:
return test_task(a=1.0, b="foo")
high-accountant-32689
01/17/2023, 6:35 PM@task
, etc), but it's a start: https://github.com/flyteorg/flytekit/pull/1372/.
I double-checked that this is supported in typing_extensions
(which also works in python 3.7 as per https://github.com/python/typing_extensions/commit/b697a12f2793655db99dde660bb47458ad36aa55), although I haven't pushed a commit that imports from there instead of typing
.elegant-australia-91422
01/17/2023, 6:37 PMhigh-accountant-32689
01/17/2023, 6:58 PM❯ mypy workflows/example2.py
workflows/example2.py:5: error: Missing positional argument "_task_function" in call to "task" [call-arg]
workflows/example2.py:5: error: Argument 1 has incompatible type "Callable[[int, float], float]"; expected <nothing> [arg-type]
Found 2 errors in 1 file (checked 1 source file)
elegant-australia-91422
01/17/2023, 6:59 PMhigh-accountant-32689
01/17/2023, 7:01 PMelegant-australia-91422
01/17/2023, 7:01 PMelegant-australia-91422
01/17/2023, 7:01 PMthankful-minister-83577
thankful-minister-83577
thankful-minister-83577
elegant-australia-91422
01/17/2023, 7:06 PMelegant-australia-91422
01/17/2023, 7:07 PMthankful-minister-83577
elegant-australia-91422
01/17/2023, 7:43 PMParamSpec
and add that to the discussion on @high-accountant-32689’s PR. We're internally pushing to improve a lot of our typing (and where possible upstream improvements to 3rd-party libs) since it's better for the iteration loop to be able to catch these obvious issues at build time