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
I am encountering an issue when trying to serialize and deserialize a Pydantic model that uses another BaseModel as dictionary keys. The deserialization process fails. Below is the code that reproduces the problem
Example Code
frompydanticimportBaseModel, ConfigDictclassCell(BaseModel):
value: strmodel_config=ConfigDict(
# make it hashablefrozen=True,
)
classWeightedSeeds(BaseModel):
seeds: dict[Cell, int]
c=Cell(value="Hello World")
seed=WeightedSeeds(seeds={c: 100})
print(WeightedSeeds.model_validate_json(seed.model_dump_json())) # Fail
Initial Checks
Description
I am encountering an issue when trying to serialize and deserialize a Pydantic model that uses another BaseModel as dictionary keys. The deserialization process fails. Below is the code that reproduces the problem
Example Code
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: