-
- Notifications
You must be signed in to change notification settings - Fork 115
Open
Labels
Description
In one of my newer projects I plan to use pydantic-settings paired with pydanclick for a declarative way to load settings from cli args and other sources such as pyproject.toml at the same time.
When thinking about it I noticed there could be cases where I don't want users to configure things from a specific source. For instance a --clean or --clear for creating a clean build in a build tool should only be possible via cli args in my opinion. Taking in this arg from other sources could lead to potentially destructive behaviour.
I think using an annotation would be the best way to implement this. I imagined it as something like this:
from pydantic_settings import BaseSettings, SettingsFieldOpts from typing import Annotated class BuildCmdSettings(BaseSettings): clean: Annotated[bool, SettingsFieldOpts(disable_sources=["PyprojectTomlConfigSettingsSource"])] = FalseSettingsFieldOpts would be a new type which could hold more options for a field if needed in the future.