Top level settings
Looking at the code it seems impossible to load settings from the top level of a Toml file. It always seems to want to get a "section" string and call .split('.')
on it. You cannot pass None
as the config_file_section
because it doesn't have a split method. Also you cannot pass ""
as the section because "".split(".")
gives you [""]
Please correct me if I'm wrong, but I don't see a way using this library to read a toml file and be able to get settings from the top level.
Example Python file
import typed_settings as ts
@ts.settings
class AppearanceSettings:
font_size: int
theme: str
@ts.settings
class Settings:
timezone: str
appearance: AppearanceSettings
settings = ts.load(Settings, appname="myapp", config_files=["/tmp/foo.toml"], config_file_section=None)
/tmp/foo.toml
timezone = "America/New_York"
[appearance]
font-size = 12
theme = "dark"