pydantic_settings.base

Module Contents

pydantic_settings.base.T
class pydantic_settings.base.BaseSettingsModel

Thin wrapper which combines pydantic.BaseModel and ModelShapeRestorer.

class Config

Model behaviour configured with Config namespace traditionally for pydantic.

env_prefix :str = APP

Expects that actual environ variables begins with given prefix, ex: 'APP_FOO' become model_instance['foo']. Respects case sensitivity option.

env_case_sensitive :bool = False

Whether ModelShapeRestorer will take environment variable case into account.

complex_inline_values_decoder

Used to decode bunch of values for some nested namespace. Assume some nested namespace with ‘foo’ location and shape like {"bar": 1, "baz": "val"}, then you able to set whole value with env variable export APP_FOO='{"bar": 2, "baz": "new_val"}'.

build_attr_docs :bool = True

Set model field descriptions taken from attributes docstrings. Read apply_attributes_docs() for further details.

override_exited_attrs_docs :bool = False

Override existed fields descriptions by attributes docs.

shape_restorer :ClassVar[ModelShapeRestorer]
classmethod from_env(cls: Type[T], environ: Mapping[str, str], *, ignore_restore_errs: bool = True, **values: Any) → T

Build model instance from given values and environ.

Parameters
  • environ – environment-like flat mapping, take precedence over values

  • ignore_restore_errs – ignore errors happened while restoring flat-mapping

  • values – values

Raises

ValidationError – in case of failure

Returns

model instance