Skip to content

Settings Merging from files doesn't allow for partial overrides #590

@rfenner

Description

@rfenner

I wrote a class to simulate the .dotenv loading of toml files where it generated the list of toml files to load in.
The problem I discovered is that the file merging is shallow ie if you have two files that both specify the same header key if you stry to override just one setting in the header from the previous file's version it wipes everything else out.

example

main.toml

[db]
host="some_host"
user="some_user"
pss="pass"
port=3306
db="soem_db

override.toml

[db]
db="some_other_db"

The data that gets loaded and then validated is

[db]
db="some_other_db"

instead of

[db]
host="some_host"
user="some_user"
pss="pass"
port=3306
db="soem_other_db

This is because the _read_files in ConfigFileSourceMixin uses the update methods of the dict which just replaces the value if the key already exists.

It would be nice to add a function that could recessively merge the dicts together that may one could do partial overrides. Thi affects all the other loaders like yaml and json as well.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions