Open zilto opened 2 weeks ago
This should be as simple as throwing the appropriate error message here
Hi @elijahbenizzy can't I just simply add:
state_model = type_hints.get("state", None)
in line 115 of pydantic.py
and then change the if
condition to raise ValueError
here
Yep, I think that will work. In fact, you don't have to have the None
there, you can just do .get(...)
which returns None
if it's not there!
Yep, I think that will work. In fact, you don't have to have the
None
there, you can just do.get(...)
which returnsNone
if it's not there!
Oh yes, thanks for reminding me that. Please let me know if if
statement is checking all the conditions correctly:
state_model = type_hints.get("state")
if state_model is None or state_model is inspect.Parameter.empty or not issubclass(state_model, pydantic.BaseModel):
raise ValueError(
f"Function fn: {fn.__qualname__} is not a valid pydantic action. "
"The 'state' parameter must be annotated with a type extending pydantic.BaseModel."
)
Hey @elijahbenizzy @zilto can anyone of you give me feedback on the if
condition?
Hey @elijahbenizzy @zilto can anyone of you give me feedback on the
if
condition?
Hey! Looks good at first glance. Open a PR and add some tests, then I can give you more feedback there!
I'm building an application with
burr.integrations.pydantic
and building the graph + application fails. The following error message isn't helpful because it exposes internal implementation (i.e., the key"state"
is nowhere in my code.The only hint is to look at "line 45", but I can't tell what's the issue. I ended up finding that the issue is the function signature on line 46.
Original:
Fix: