Skip to content

dynaconf_merge = false supported? #835

@westphal-jan

Description

@westphal-jan

Hello, I would like to know if it is possible to disable merging for some keys of a configs. In our case, we have a bunch of config files (~30) and merging them is the usual behavior. We do this through the Dynaconf parameter merge_enabled. Now, in a few cases the merging leads to undesired behavior and it would be nice to turn off merging for these specific config keys. Is it possible to do this easily without changing up the default merge behavior and touch all the config files? I tried dynaconf_merge = false as a property but this behavior doesn't seem to be supported.

Example:
1.toml

[general]
a = 1

[other]
a = 2

2.toml

[general]
b = 1

[other]
dynaconf_merge = false
b = 2

config.py

from dynaconf import Dynaconf

settings = Dynaconf(
    settings_files=["1.toml", "2.toml"],
    merge_enabled=True,
)

print(settings.to_dict())

Output:

{'GENERAL': {'b': 1, 'a': 1}, 'OTHER': {'b': 2, 'a': 2}}

Expected Output:

{'GENERAL': {'b': 1, 'a': 1}, 'OTHER': {'b': 2}}

Thanks for your time.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions