Closed MickVermeulen closed 3 months ago
Thanks @MickVermeulen for reporting this. but we reverted this change on https://github.com/pydantic/pydantic-settings/commit/b3a67e92d6d4f58d35c47732fec34d7cda9d7df2 and it is available in pydantic-settings 2.2.1
Due to a change in 2784a7013d0bccb5c76c2db78befe0c266baac55 to
dump_python
any of the init kwargs, any nested structure of models is dumped to a dictionary, including default fields. This dictionary is then later used to instantiate theBaseSettings
model itself, which causes all fields on child models to be set.Take for example the following minimum example:
Even though the
foo
property onChild
is never explicitly set, it will show up undermodel_fields_set
.Would there be some way to retrieve the original behaviour? I actually rely on this to be able to merge models myself. Overriding defaults becomes difficult when
model_fields_set
is not correct as you can no longer keep a default value apart from a user-defined value that happens to overlap with a default value.