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
Originally posted by LordFckHelmchen May 9, 2022
Dear Pydantic devs.
When I have pydantic class that contains an Set field (non-serializable), with default value, I get an TypeError: Object of type set is not JSON serializable when using json.dump. However, when removing the default value, everything works and the generated schema correctly uses the array type for the Set.
The error can also be solved by using the pydantic encoder in the dump call. Then also the default value is correctly typed.
I'm not sure if this is an issue or intended - therefore tried in the discussion section first (but it might also be related to issue #2470).
Discussed in #4053
Originally posted by LordFckHelmchen May 9, 2022
Dear Pydantic devs.
When I have pydantic class that contains an
Set
field (non-serializable), with default value, I get anTypeError: Object of type set is not JSON serializable
when usingjson.dump
. However, when removing the default value, everything works and the generated schema correctly uses thearray
type for theSet
.The error can also be solved by using the pydantic encoder in the dump call. Then also the default value is correctly typed.
I'm not sure if this is an issue or intended - therefore tried in the discussion section first (but it might also be related to issue #2470).
Thanks for any ideas!
Greetings
Setup
Minimal working examples
TypeError with default
Code
Result
No error without default
Code
Result
No error with pydantic encoder
Code
Result
The text was updated successfully, but these errors were encountered: