-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function parameters are not hinted at since the Flow comes back as Any type variable. #5354
Comments
Hi! This is primarily a consequence of the novelty of typing in Python. The language has only recently added support for maintaining type signatures on decorated functions like this. Prefect Orion supports this, but it only works with It is likely that our team will focus on supporting this cleanly in Orion rather than attempting to add compatibility here. I'd be willing to review a PR that backports the Orion implementation though. |
Sorry to resuscitate, do you know if this is fixed yet in mypy/prefect? Using Python from prefect import flow, task
@task
def task_one() -> int:
return 1
@flow
def main() -> None:
res = task_one()
reveal_type(res) |
This issue is stale because it has been open 30 days with no activity. To keep this issue open remove stale label or comment. |
Description
With modern development tooling, when you implement a function, you will see a list of variables the function expects.
When you write a function as a Task using the Prefect @task decorator, it hides the parameters since the return type is 'FunctionTask'.
Expected Behavior
The IDE should be able to show the expected parameters, even if they have to be annotated in the @task decorator somehow. This way when building tasks (especially a large number of tasks), you can see what the task expects when you attempt to use it in your flow.
Reproduction
Create a Task function (decorated with @task), then when using it in the Flow you will not see any hints as to what variables it expects, or if any at all.
Environment
Linux ubuntu 20.04 docker container, using visual studio code, with python extension installed.
Optionally run
prefect diagnostics
from the command line and paste the information here. -->{
"config_overrides": {},
"env_vars": [
"PREFECT__CLOUD__USE_LOCAL_SECRETS",
"PREFECT__CLOUD__API_KEY"
],
"system_information": {
"platform": "Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.28",
"prefect_backend": "cloud",
"prefect_version": "0.15.12",
"python_version": "3.9.6"
}
}
The text was updated successfully, but these errors were encountered: