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
In the end, in every programming environment from excel upwards, if you try hard enough to break things, you can break things.
I would consider this to come into the "try hard enough and you can break things" category.
Either way, I don't think we should make fundamental changes like this in pydantic v1. If we make a change to this, it should be in pydantic-core. Partly because of performance and partly because some people might be using this "feature".
Hi @samuelcolvin , thanks for taking time to answer!
That's pretty annoying for a library targeting validation as a major feature to have such corner cases.
Do you have some microbenchmarks somewhere to run and see what are the real impacts on perfs?
Another approach could be to use a class wrapper to access the underlying object (dict for GetterDict) without exposing the __setitem__ to avoid such use. That way there is no copy construction but only taking a ref and an additional indirection, pretty cheap.
I'm not sure this kind of use should be consider as a feature. This much more looks like a rabbit hole for people having to debug such a case ;)
Checks
Bug
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:Hi!
The fields values are mutable after validation in constructor and it may invalidate previsouly validated field:
I suggest to use a copy or similar approach on values in
validated_model
https://github.com/samuelcolvin/pydantic/blob/eadfdbdbde3d4d8363b69196bbe4dded956982c3/pydantic/main.py#L1038
The text was updated successfully, but these errors were encountered: