-
-
Notifications
You must be signed in to change notification settings - Fork 334
Open
Labels
Description
Currently, I see only two ways to specify value types when loading configuration provider from file:
- To declare additional provider with value conversion
- To convert value each time it used in Provide, like
Provide[Container.config.port.as_int()]
, which leads to repetition and pain when you need to change value type
In my opinion, both ways do not take advantage of declarative approach for configs
I propose folloving solution/feature - type specification, declared as kwarg (nested dict) in providers.Configuration initialization, same way asdefault
kwarg, where each value is either type or callable that performs conversion during config loading process.
Example syntax:
config = providers.Configuration(specification={"port": int, "bind": bool_converter_func})
Would be grateful for feedback or alternative approaches I missed
jochenparm and rmk135