Skip to content

Optional config from file #61

@Teivaz

Description

@Teivaz

I need to create a user configuration file that if present would override the basic config.

base.config.json - checked in
config.json - gitignore

But the following code does not work. I need to separately check for the config file and then modify the configuration sources.

cfg = ConfigurationSet(
    config_from_env(prefix="app_config"),
    config_from_json("config.json", read_from_file=True), # Throws error when file is not present
    config_from_json("base.config.json", read_from_file=True),
)

It would be nice to have this case handled by the library instead. The interface can look like this:

config_from_json("config.json", read_from_file=True, file_optional=True)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions