CodeVetter · Repo Unpack · Extension points
pydantic/pydantic-settings
Customization centers on explicit source composition rather than automatic plugin discovery. Sources can reuse field preparation and observe higher-priority state. CLI extensions use model metadata and an argparse-compatible adapter surface. File readers, cloud-client injection, validation hooks, and public exports provide additional concrete places to extend behavior.
- Override settings_customise_sources to add, remove, or reorder dictionary-producing sources; its tuple establishes highest-first priority, and the orchestrator appends DefaultSettingsSource afterward.
- Subclass PydanticBaseSettingsSource and implement get_field_value/__call__; inherited prepare_field_value, field_is_complex, and decode_complex_value supply reusable conversion hooks.
- Dependent sources can read current_state and settings_sources_data populated immediately before __call__; GCP project resolution is an implemented example of consuming prior-source state.
- New structured-file providers can combine ConfigFileSourceMixin with InitSettingsSource and implement _read_file, retaining shared multi-file ordering, optional deep merging, and alias normalization.
- CliSettingsSource accepts an external root_parser and injectable parse/add/group/subparser/help methods; adapters must honor argparse-compatible signatures, and external parsers cannot request case-insensitive matching.
- CLI Annotated helpers and CliMutuallyExclusiveGroup extend model-driven parser generation; _CliArg and _parser_map connect field metadata to argument destinations, subcommand models, and serialization.
- CliApp accepts an alternate cli_cmd_method_name, while Pydantic validators can transform or check the model after settings acquisition; inspected tests exercise alternate command dispatch and an after-model validator.
- GCP supports prebuilt secret_client injection and SecretVersion field metadata; adding public APIs or provider dependencies also involves the explicit package exports and optional-extras manifest.