pydantic-core icon indicating copy to clipboard operation
pydantic-core copied to clipboard

remove self reference from serializer

Open samuelcolvin opened this issue 1 year ago • 2 comments

samuelcolvin avatar Mar 06 '23 15:03 samuelcolvin

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

dmontagu avatar Mar 06 '23 16:03 dmontagu

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."

robertofd1995 avatar Aug 08 '23 16:08 robertofd1995