Skip to content
You're viewing docs for v2.0. See the latest version →

pydantic.config

Configuration for Pydantic models.

BaseConfig

This class is only retained for backwards compatibility.


PydanticDeprecatedSince20

Bases: PydanticDeprecationWarning

A specific PydanticDeprecationWarning subclass defining functionality deprecated since Pydantic 2.0.


ConfigDict

Bases: TypedDict

A dictionary-like class for configuring Pydantic models.

Attributes

title

Type: str | None

str_to_lower

Type: bool

str_to_upper

Type: bool

str_strip_whitespace

Type: bool

str_min_length

Type: int

str_max_length

Type: int | None

extra

Type: ExtraValues | None

frozen

Type: bool

populate_by_name

Type: bool

use_enum_values

Type: bool

validate_assignment

Type: bool

arbitrary_types_allowed

Type: bool

from_attributes

Type: bool

loc_by_alias

Type: bool

alias_generator

Type: Callable[[str], str] | None

ignored_types

Type: tuple[type, ...]

allow_inf_nan

Type: bool

json_schema_extra

Type: dict[str, object] | JsonSchemaExtraCallable | None

strict

Type: bool

revalidate_instances

Type: Literal['always', 'never', 'subclass-instances']

ser_json_timedelta

Type: Literal['iso8601', 'float']

ser_json_bytes

Type: Literal['utf8', 'base64']

validate_default

Type: bool

validate_return

Type: bool

protected_namespaces

Type: tuple[str, ...]

hide_input_in_errors

Type: bool


getattr_migration

def getattr_migration(module: str) -> Callable[[str], Any]

Implement PEP 562 for objects that were either moved or removed on the migration to V2.

Returns

Callable[[str], Any] — A callable that will raise an error if the object is not found.

Parameters

module : str

The module name.


DeprecationWarning

Default: PydanticDeprecatedSince20

JsonSchemaExtraCallable

Type: TypeAlias Default: Union[Callable[[Dict[str, Any]], None], Callable[[Dict[str, Any], Type[Any]], None]]

Extra

Default: _Extra()

ExtraValues

Default: Literal['allow', 'ignore', 'forbid']