Open
Description
Hi - this is a very nice lib! Just reporting something I saw
from pydantic_partials import PartialModel, MissingType, Missing
from pydantic import computed_field
class Test(PartialModel):
a: int
@computed_field
@property
def b(self) -> int | MissingType:
if a < 2:
return Missing
return a
t = Test(a=1)
t.model_dump_json()
raises
.local/lib/python3.11/site-packages/pydantic/main.py", line 415, in model_dump_json
return self.__pydantic_serializer__.to_json(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.PydanticSerializationError: Unable to serialize unknown type: <class 'pydantic_partials.sentinels.MissingType'>
Instead, I would expect it to drop the computed_fields.
This is nit.
Versions
pydantic-partials: 1.1.0
pydantic: 2.8.2
Metadata
Metadata
Assignees
Labels
No labels