You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Python 3.12 with Beanie and a Pydantic (v2) model that has a union-typed field using a discriminated union (via Annotated), Beanie's internal encoder raises a TypeError because it attempts to do an isinstance() check against subscripted generics.
Describe the bug
When using Python 3.12 with Beanie and a Pydantic (v2) model that has a union-typed field using a discriminated union (via
Annotated
), Beanie's internal encoder raises aTypeError
because it attempts to do anisinstance()
check against subscripted generics.See https://bugs.python.org/issue44529
To Reproduce
Expected behavior
Handle these union-typed fields without errors.
Actual behavior
Because Beanie's internal
_get_encoder
does something like:Additional context
I've had to monkey-patch Beanie's
_get_encoder
to work around this issue:The text was updated successfully, but these errors were encountered: