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
I tried adding an additional config file to a Dynaconf instance with global merge set to True and found that a nested list was normally merged when I needed it to be unique or not merged at all as the old value was contained in the new value so the result list had duplicate items.
I thought about using a set instead but the order is important in this case
I'd like to be able to use dynaconf_merge_unique inside nested lists
Another alternative could be using the local_merge flag to allow disabling the merge for a specific nested value.
Although this alternative is more robust and general, it requires a more complex change than enabling the unique flag in nested lists
A possible solution for enabling the unique flag in nested lists is to add the following lines right before running object_merge on nested values (for Dynaconf 3.1.7 it stays in dynaconf/utils/__init__.py:77).
unique = ("dynaconf_merge_unique" in value)
if unique:
value.remove("dynaconf_merge_unique")
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I tried adding an additional config file to a Dynaconf instance with global merge set to
True
and found that a nested list was normally merged when I needed it to be unique or not merged at all as the old value was contained in the new value so the result list had duplicate items.I thought about using a set instead but the order is important in this case
I'd like to be able to use
dynaconf_merge_unique
inside nested listsAnother alternative could be using the
local_merge
flag to allow disabling the merge for a specific nested value.Although this alternative is more robust and general, it requires a more complex change than enabling the unique flag in nested lists
Example:
defaults.yaml
additional_config.yaml
Result config dictionary:
A possible solution for enabling the unique flag in nested lists is to add the following lines right before running
object_merge
on nested values (for Dynaconf 3.1.7 it stays indynaconf/utils/__init__.py:77
).The text was updated successfully, but these errors were encountered: