Skip to content

TOMLSource

A ConfigSource that loads values from a TOML file.

Warning

In order to use this source you must have toml installed either directly or by including the "toml" extra when installing this package (e.g. poetry install flex-config -E toml).

Parameters:

Name Type Description Default
path pathlib.Path

a pathlib.Path to a TOML file to load.

required
path_must_exist bool

if true, the constructor will raise a RuntimeError if the provided path doesn't exist.

required

_load_file(self, file) private

Loads and parses the TOML file

Source code in flex_config\file_sources\toml_source.py
35
36
37
38
39
40
def _load_file(self, file: TextIO) -> Dict[str, Any]:
    """ Loads and parses the TOML file """
    import toml

    config_dict = toml.load(file)
    return cast(Dict[str, Any], config_dict)