You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use pydantic for handling pyproject.toml configuration, I would like to be able to pass a custom path to the PyprojectTomlConfigSettingsSource. This is possible for the TomlConfigSettingsSource source, but that lacks the pyproject.toml support (very minor layer to get the tool.my-tool section of the Toml file. For PyprojectTomlConfigSettingsSource, the settings_cls.model_config.get('toml_file') lookup is missing.
sbrugman
changed the title
PyprojectTomlConfigSettingsSource overwrite toml_file_path from model_config
PyprojectTomlConfigSettingsSource overwrite toml_file Path from model_configSep 19, 2024
Thanks @sbrugman for reporting this issue. Yeah, the PyprojectTomlConfigSettingsSource doesn't consider the toml_file in the config. actually, it doesn't have any config.
BTW, I would suggest defining a new config for PyprojectTomlConfigSettingsSource because toml_file accepts list of files but PyprojectTomlConfigSettingsSource accepts one file. also, if we enable both PyprojectTomlConfigSettingsSource and TomlConfigSettingsSource sources together, it will be confusing.
I would suggest defining pyproject_toml_file for this source.
To use pydantic for handling
pyproject.toml
configuration, I would like to be able to pass a custom path to thePyprojectTomlConfigSettingsSource
. This is possible for theTomlConfigSettingsSource
source, but that lacks thepyproject.toml
support (very minor layer to get thetool.my-tool
section of the Toml file. ForPyprojectTomlConfigSettingsSource
, thesettings_cls.model_config.get('toml_file')
lookup is missing.toml_file
is ignored:toml_file
is respected:It looks like a fairly simple and straight-forward enhancement in
sources.py
.My current workaround is to create a custom class with elements of both classes:
Would be great if this functionality can come out-of-the-box.
The text was updated successfully, but these errors were encountered: