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
Is your feature request related to a problem? Please describe.
in the test automation for insights we use a dynaconf object for the overall configuration,
in some tests components must create a version of the configuration for the current environment with changes applied
for_env(...) unfortunately returns objects that change the original configuration
deepcopy unfortunately fails for our config objects with exceptions about modules not being pickle-able
Describe the solution you'd like
mysettings.copy_with_changes(**data_to_merge_in_on_top) creates a new settings object that allows wont affect mysettings and can be used
Describe alternatives you've considered
creating fresh configurations every time -> currently takes a while and also takes away potential/intended code based changes of the settings objects
The text was updated successfully, but these errors were encountered:
RonnyPfannschmidt
changed the title
[RFC] creae a easy way to create a copy/view of a config with changes applied
[RFC] create a easy way to get a copy/view of a config with changes applied
Feb 10, 2021
This is something I'd love to see as well. Despite __deepcopy__ and __copy__ being defined on the settings, using either throws an exception, so our current solution is to reload the settings, apply the overrides, get the _store, copy that, then reload the settings again, which is incredibly slow.
@timhoffm that would be a hazardous foot gun if one uses anything that consumes the config to create nin volatile state (like db./api clients with wrong credentials)
with settings.using_env("development", **changes):
# do something with
# back to normal
Notice that this is not thread safe and will be deprecated on 4.0.0 in favour of some new approach that will either be a .copy or the same context manager but returning a copy instead of mutating the same object
Is your feature request related to a problem? Please describe.
in the test automation for insights we use a dynaconf object for the overall configuration,
in some tests components must create a version of the configuration for the current environment with changes applied
for_env(...)
unfortunately returns objects that change the original configurationdeepcopy
unfortunately fails for our config objects with exceptions about modules not being pickle-ableDescribe the solution you'd like
mysettings.copy_with_changes(**data_to_merge_in_on_top)
creates a new settings object that allows wont affect mysettings and can be usedDescribe alternatives you've considered
The text was updated successfully, but these errors were encountered: