Skip to content

[Feature request] Config provider type/converter specification/declaration #468

Open
@artem30801

Description

@artem30801

Currently, I see only two ways to specify value types when loading configuration provider from file:

  1. To declare additional provider with value conversion
  2. 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 as default 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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions