Closed fantix closed 5 months ago
When returning edgedb-python query results directly as a FastAPI response as demonstrated in the tutorial, the objects are inferred as dataclass by Pydantic, and serialized directly through the dict from dataclass. Both edgedb-python and Pydantic in this case are native Python extensions.
Hey @fantix -- what's the status of getting this CR reviewed? Thanks!
Bumping this one more time, any update on getting this CR approved? Guessing the above comment got lost in the Holiday scuffle. @1st1 @fantix ?
Thanks!
Sorry yeah, I'm hoping to get a review and put out a new release in a day or two
Thanks @fantix !
Background:
TypeAdapter
needs to look back in the stack for typing context (e.g. in globals). Therefore, FastAPI cannot currently use non-Pydantic types with forward type references properly.__get_validators__()
in favor of the new schema design.Solution:
Skip constructing
dataclass
schema under Pydantic v2 through__get_pydantic_core_schema__()
, which:__get_validators__()
, so the latter can stay for v1 compatibility.Fixes #466