-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
pydantic/pydantic-core
#1660Labels
bug V2Bug related to Pydantic V2Bug related to Pydantic V2
Description
Initial Checks
- I confirm that I'm using Pydantic V2
Description
i also reported this in pydantic/pydantic-core#1651
import pydantic
class MyModel(pydantic.RootModel):
root: str
@pydantic.model_serializer(mode="wrap")
def my_wrapper_serializer(self, serializer: pydantic.SerializerFunctionWrapHandler):
return "my_prefix:" + serializer(self)
class MyParentModel(pydantic.BaseModel):
nested: MyModel
@pydantic.field_serializer('nested', mode="wrap")
def wrapped_field_serializer(
self, field_value, serializer: pydantic.SerializerFunctionWrapHandler
):
return serializer(field_value)
if __name__ == "__main__":
my_model = MyParentModel.model_validate({'nested': "validated_value"})
print(my_model.model_dump())
#>expected: {'nested': 'my_prefix:validated_value'}
#>actual: {'nested': 'my_prefix:my_prefix:validated_value'}
this didn't happen before the bump to pydantic-core 2.29.0.
Example Code
Python, Pydantic & OS Version
pydantic version: 2.11.0a1
pydantic-core version: 2.29.0
pydantic-core build: profile=release pgo=false
install path: C:\Users\me\AppData\Local\pypoetry\Cache\virtualenvs\myproject-py3.13\Lib\site-packages\pydantic
python version: 3.13.0 (tags/v3.13.0:60403a5, Oct 7 2024, 09:38:07) [MSC v.1941 64 bit (AMD64)]
platform: Windows-10-10.0.19045-SP0
related packages: mypy-1.15.0 typing_extensions-4.12.2
commit: unknown
Metadata
Metadata
Assignees
Labels
bug V2Bug related to Pydantic V2Bug related to Pydantic V2