-
-
Notifications
You must be signed in to change notification settings - Fork 113
Closed
Labels
Description
Currently, you can declare a model like this:
class Settings(BaseSettings):
dry_run: bool = False
model_config = SettingsConfigDict(
cli_parse_args=True,
alias_generator=AliasGenerator(
validation_alias=lambda s: AliasChoices(s, to_snake(s).replace("_", "-"))
),
)and end up with an application you can run in dry-run mode by running myapp --dry-run=true. But this is not exactly what is usually expected of CLI applications; usually, boolean flags are argumentless (--dry-run, --force, etc.) and their presence implies the associated value is true. Sometimes they have an inverse like --no-dry-run which implies the opposite.
I don't think pydantic-settings currently supports arguments like this. It would be very useful if it did :)
FynnBe, vladvalkov and atonem