lundybernard / batconf

Application configuration tool from the BAT project
MIT License
2 stars 0 forks source link

Handle falsey return values from sources #17

Open lundybernard opened 1 year ago

lundybernard commented 1 year ago

https://github.com/lundybernard/batconf/blob/412297bfa4af6572303d772e907ced32f1ab1a6b/batconf/source.py#L27

Currently, if a source returns a falsey value (False, None, 0, etc.) it will be ignored, and we will continue on to the next source. Falsey values can be valid configuration options, so we need to distinguish a valid None value in a config from a value Not Found None.

Test Cases:

lundybernard commented 7 months ago

Proposed solution: We will only officially support String values in configuration sources. Converting string values to other types will be the responsibility of the application.

This is more aligned with Environment Variable, and CLI sources, and seems to be common among other configuration storage services.

We will not actively prevent custom sources from returning non-string values, but Falsey values will continue to be a known problem if you choose to do so.

We may consider a more complex solution, raising exceptions instead of returning None, in the future if a compelling use-case presents its self.