Morten Hauge
10/25/2023, 10:17 AMFailed(message=...)
from one of my tasks. I can type-annotate this function to say that it returns either an object or a state, but this seems like more negative engineering in my calling code when in 99% of all cases it returns an object. When calling .fn()
in my test return_state
is not available as a parameter, which would inform my type-checker that the result is actually a state.
Is there a better way to fail my pipeline, or a better way to perform this assert in my test?Morten Hauge
10/25/2023, 10:40 AMfrom prefect.server.schemas.states import State
maybe_result = tasks.some_task(p1="test")
assert isinstance(maybe_result, State)
assert maybe_result.is_failed()
This allows the type-checker to verify that the is_failed
method exists on maybe_result
.