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
Using pydantic for deserialization, the ASDF serialized node of the YAML tree comes in as a asdf.tagged.TaggedDict. Pydantic is having trouble validating this as if it's a regular dictionary. I identified this being due to TaggedDict having multiple-inheritance to both UserDict and dict. I have not seen examples where this is the intended implementation for custom dicts.
Example of the problem
fromcollectionsimportUserDictfromasdf.taggedimportTaggedDictfrompydanticimportBaseModelclassBar(BaseModel):
a: intclassFoo(BaseModel):
bar: BarFoo.model_validate({"bar": {"a": 1}})
Foo.model_validate({"bar": TaggedDict({"a": 1})})
pydantic_core._pydantic_core.ValidationError: 1 validation error for Foo
bar.a
Field required [type=missing, input_value={'a': 1}, input_type=TaggedDict]
For further information visit https://errors.pydantic.dev/2.9/v/missing
pydantic_core._pydantic_core.ValidationError: 1 validation error for Foo
bar.a
Field required [type=missing, input_value={'a': 1}, input_type=MultiInheritanceDict]
For further information visit https://errors.pydantic.dev/2.9/v/missing
The text was updated successfully, but these errors were encountered:
ketozhang
changed the title
TaggedDict multiple inheritance is causing issues
TaggedDict multiple inheritance is causing issues with Pydantic
Nov 18, 2024
ketozhang
changed the title
TaggedDict multiple inheritance is causing issues with Pydantic
TaggedDict multiple inheritance is failing Pydantic validation
Nov 18, 2024
Description of the problem
Using pydantic for deserialization, the ASDF serialized node of the YAML tree comes in as a
asdf.tagged.TaggedDict
. Pydantic is having trouble validating this as if it's a regular dictionary. I identified this being due toTaggedDict
having multiple-inheritance to bothUserDict
anddict
. I have not seen examples where this is the intended implementation for custom dicts.Example of the problem
Success on simplest single-inheritance.
Fails on simplest multi-inheritance
System information
asdf version: 3.5.0
python version: 3.12.7
operating system: OSX 14.6.1
The text was updated successfully, but these errors were encountered: