pydantic / pydantic-core

Core validation logic for pydantic written in rust
MIT License
1.4k stars 232 forks source link

remove self reference from serializer #420

Open samuelcolvin opened 1 year ago

dmontagu commented 1 year ago

Because I just worked through this, in case it's helpful, the specific (and only, as far as I can tell) spot where a circular reference is currently working its way into the serializer is through the cls field of the outer_schema being passed to the SchemaSerializer here:

https://github.com/pydantic/pydantic/blob/6ab42070483907d70e62c2b2fea37832e7c2748d/pydantic/_internal/_model_construction.py#L181-L188

robertofd1995 commented 1 year ago

Think this issue also related to this one https://github.com/pydantic/pydantic/issues/6736

"Additionally I saw that if I make that attribute private, when calling to the function attribute it sends over self as argument, when I would not expect that behaviour."