Support using a table header as root when reading a TOML file - #882
Conversation
06dd021 to
e7b7f78
Compare
|
|
||
| s = Settings() | ||
| assert s.model_dump() == {'hello': 'world', 'nested': {'foo': 3, 'bar': 2 if deep_merge else 0}} | ||
|
|
There was a problem hiding this comment.
Could you add a test for the case where toml_table_header references a key that doesn't exist in the TOML file? Currently self.toml_data.get(key, {}) silently returns {}, which would result in missing/default field values. It'd be good to have a test that documents this behavior explicitly.
There was a problem hiding this comment.
@hramezani Nice catch! I added a test for the missing table header, and an explicit error, based on how it's done with yaml_config_section.
|
Thanks @whyscream for the PR.
It should be:
Without this, if a user sets toml_table_header in model_config but forgets to add a TomlConfigSettingsSource to their sources, they won't get the expected warning. |
1f66cd4 to
247f39d
Compare
|
Thanks @whyscream |
Support
toml_table_headerfor regular TOML files.It can be set from
model_configor fromsettings_customise_sources.Resolves #881