pydantic / pydantic-settings

Settings management using pydantic

Home Page:https://docs.pydantic.dev/latest/usage/pydantic_settings/

Repository from Github https://github.compydantic/pydantic-settingsRepository from Github https://github.compydantic/pydantic-settings

Allow setting env_nested_delimiter for CliSettingsSource

tmchartrand opened this issue · comments

The delimiter is hardcoded to '.' for CliSettingsSource, but in some cases it would be helpful to allow the user to adjust that default!

https://github.com/pydantic/pydantic-settings/blob/9380bc653d0d5b712ea85230608854d898947ec8/pydantic_settings/sources/providers/cli.py#L234C13-L234C33

@kschwab what do you think?

Hi @tmchartrand, is there a strong use case for this? I think waiting to see if there is more demand for this feature might make more sense.

I imagine it's not especially common, but we work with a no-code app interface that passes parameters to python via command line args, and for some strange reason has character restrictions that exclude "." in parameter names. Using CliSettingsSource would otherwise be super convenient for parsing arguments, but nested parameters are currently impossible.

This seems like a very small and non-consequential change, I could try to submit a PR if it would be welcome.