What are the recommended best practices for typing...
# pacc-jan-28-29-2025
j
What are the recommended best practices for typing with prefect? I've tried both mypy and pyright and each have issues with the way that the types are defined in prefect. Here is a simple example from the lab
j
Type completeness was just achieved in 3.1.13 and should work well. Is this using 3.1.14? https://github.com/PrefectHQ/prefect/releases/tag/3.1.13
j
Ya, 3.1.14
btw, so glad to hear that typing is a priority.
👍 1
j
Talked to our engineer who is working on it a bunch. He said: That will be fixed when we fix our sync and async interfaces. If you want to work around this unpleasantness, you can do this:
Copy code
from prefect import flow
from prefect.flows import Flow

if __name__ == "__main__":
    my_flow = flow.from_source(
        source="<https://github.com/prefecthq/pacc-2024-v6.git>",
        entrypoint="102/weather2-tasks-fail.py:pipeline",
    )
    assert isinstance(my_flow, Flow)
    my_flow.deploy(name="default")
BTW, Astral is building a static type checker for Python in Rust. Discussion linked here: https://github.com/astral-sh/ruff/issues/3893.
j
YES!!
Ya, the sync/async interfaces are pretty tough to use right now
j