default_factory
in dataclasses behaves strange when set to a callable object instead of a function
#8510
Labels
bug V2
Bug related to Pydantic V2
Initial Checks
Description
There seems to be an unexpected difference with
default_factory
withpydantic.dataclasses
in a very specific case.It happens in this case:
default_factory
set to the same callable object.It seems that the callable object (used for
default_factory
) gets copied (duplicated) at some point before being called. This can cause some unexpected behaviour, as shown in the tests below.Example Code
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: