@@ -54,8 +54,6 @@ class CoreConfig(TypedDict, total=False):
5454 `field_names` to construct error `loc`s. Default is `True`.
5555 revalidate_instances: Whether instances of models and dataclasses should re-validate. Default is 'never'.
5656 validate_default: Whether to validate default values during validation. Default is `False`.
57- populate_by_name: Whether an aliased field may be populated by its name as given by the model attribute,
58- as well as the alias. (Replaces 'allow_population_by_field_name' in Pydantic v1.) Default is `False`.
5957 str_max_length: The maximum length for string fields.
6058 str_min_length: The minimum length for string fields.
6159 str_strip_whitespace: Whether to strip whitespace from string fields.
@@ -74,6 +72,9 @@ class CoreConfig(TypedDict, total=False):
7472 regex_engine: The regex engine to use for regex pattern validation. Default is 'rust-regex'. See `StringSchema`.
7573 cache_strings: Whether to cache strings. Default is `True`, `True` or `'all'` is required to cache strings
7674 during general validation since validators don't know if they're in a key or a value.
75+ validate_by_alias: Whether to validate by alias. Default is `True`.
76+ validate_by_name: Whether to validate by attribute name. Default is `False`. Replacement for `populate_by_name`.
77+ serialize_by_alias: Whether to serialize by alias. Default is `False`, expected to change to `True` in V3.
7778 """
7879
7980 title : str
@@ -91,7 +92,6 @@ class CoreConfig(TypedDict, total=False):
9192 # whether to validate default values during validation, default False
9293 validate_default : bool
9394 # used on typed-dicts and arguments
94- populate_by_name : bool # replaces `allow_population_by_field_name` in pydantic v1
9595 # fields related to string fields only
9696 str_max_length : int
9797 str_min_length : int
@@ -111,6 +111,9 @@ class CoreConfig(TypedDict, total=False):
111111 coerce_numbers_to_str : bool # default: False
112112 regex_engine : Literal ['rust-regex' , 'python-re' ] # default: 'rust-regex'
113113 cache_strings : Union [bool , Literal ['all' , 'keys' , 'none' ]] # default: 'True'
114+ validate_by_alias : bool # default: True
115+ validate_by_name : bool # default: False
116+ serialize_by_alias : bool # default: False
114117
115118
116119IncExCall : TypeAlias = 'set[int | str] | dict[int | str, IncExCall] | None'
@@ -2888,7 +2891,6 @@ class TypedDictSchema(TypedDict, total=False):
28882891 # all these values can be set via config, equivalent fields have `typed_dict_` prefix
28892892 extra_behavior : ExtraBehavior
28902893 total : bool # default: True
2891- populate_by_name : bool # replaces `allow_population_by_field_name` in pydantic v1
28922894 ref : str
28932895 metadata : dict [str , Any ]
28942896 serialization : SerSchema
@@ -2904,7 +2906,6 @@ def typed_dict_schema(
29042906 extras_schema : CoreSchema | None = None ,
29052907 extra_behavior : ExtraBehavior | None = None ,
29062908 total : bool | None = None ,
2907- populate_by_name : bool | None = None ,
29082909 ref : str | None = None ,
29092910 metadata : dict [str , Any ] | None = None ,
29102911 serialization : SerSchema | None = None ,
@@ -2938,7 +2939,6 @@ class MyTypedDict(TypedDict):
29382939 metadata: Any other information you want to include with the schema, not used by pydantic-core
29392940 extra_behavior: The extra behavior to use for the typed dict
29402941 total: Whether the typed dict is total, otherwise uses `typed_dict_total` from config
2941- populate_by_name: Whether the typed dict should populate by name
29422942 serialization: Custom serialization schema
29432943 """
29442944 return _dict_not_none (
@@ -2950,7 +2950,6 @@ class MyTypedDict(TypedDict):
29502950 extras_schema = extras_schema ,
29512951 extra_behavior = extra_behavior ,
29522952 total = total ,
2953- populate_by_name = populate_by_name ,
29542953 ref = ref ,
29552954 metadata = metadata ,
29562955 serialization = serialization ,
@@ -3012,9 +3011,7 @@ class ModelFieldsSchema(TypedDict, total=False):
30123011 computed_fields : list [ComputedField ]
30133012 strict : bool
30143013 extras_schema : CoreSchema
3015- # all these values can be set via config, equivalent fields have `typed_dict_` prefix
30163014 extra_behavior : ExtraBehavior
3017- populate_by_name : bool # replaces `allow_population_by_field_name` in pydantic v1
30183015 from_attributes : bool
30193016 ref : str
30203017 metadata : dict [str , Any ]
@@ -3029,7 +3026,6 @@ def model_fields_schema(
30293026 strict : bool | None = None ,
30303027 extras_schema : CoreSchema | None = None ,
30313028 extra_behavior : ExtraBehavior | None = None ,
3032- populate_by_name : bool | None = None ,
30333029 from_attributes : bool | None = None ,
30343030 ref : str | None = None ,
30353031 metadata : dict [str , Any ] | None = None ,
@@ -3058,7 +3054,6 @@ def model_fields_schema(
30583054 ref: optional unique identifier of the schema, used to reference the schema in other places
30593055 metadata: Any other information you want to include with the schema, not used by pydantic-core
30603056 extra_behavior: The extra behavior to use for the typed dict
3061- populate_by_name: Whether the typed dict should populate by name
30623057 from_attributes: Whether the typed dict should be populated from attributes
30633058 serialization: Custom serialization schema
30643059 """
@@ -3070,7 +3065,6 @@ def model_fields_schema(
30703065 strict = strict ,
30713066 extras_schema = extras_schema ,
30723067 extra_behavior = extra_behavior ,
3073- populate_by_name = populate_by_name ,
30743068 from_attributes = from_attributes ,
30753069 ref = ref ,
30763070 metadata = metadata ,
@@ -3254,7 +3248,6 @@ class DataclassArgsSchema(TypedDict, total=False):
32543248 dataclass_name : Required [str ]
32553249 fields : Required [list [DataclassField ]]
32563250 computed_fields : list [ComputedField ]
3257- populate_by_name : bool # default: False
32583251 collect_init_only : bool # default: False
32593252 ref : str
32603253 metadata : dict [str , Any ]
@@ -3267,7 +3260,6 @@ def dataclass_args_schema(
32673260 fields : list [DataclassField ],
32683261 * ,
32693262 computed_fields : list [ComputedField ] | None = None ,
3270- populate_by_name : bool | None = None ,
32713263 collect_init_only : bool | None = None ,
32723264 ref : str | None = None ,
32733265 metadata : dict [str , Any ] | None = None ,
@@ -3295,7 +3287,6 @@ def dataclass_args_schema(
32953287 dataclass_name: The name of the dataclass being validated
32963288 fields: The fields to use for the dataclass
32973289 computed_fields: Computed fields to use when serializing the dataclass
3298- populate_by_name: Whether to populate by name
32993290 collect_init_only: Whether to collect init only fields into a dict to pass to `__post_init__`
33003291 ref: optional unique identifier of the schema, used to reference the schema in other places
33013292 metadata: Any other information you want to include with the schema, not used by pydantic-core
@@ -3307,7 +3298,6 @@ def dataclass_args_schema(
33073298 dataclass_name = dataclass_name ,
33083299 fields = fields ,
33093300 computed_fields = computed_fields ,
3310- populate_by_name = populate_by_name ,
33113301 collect_init_only = collect_init_only ,
33123302 ref = ref ,
33133303 metadata = metadata ,
@@ -3436,7 +3426,8 @@ def arguments_parameter(
34363426class ArgumentsSchema (TypedDict , total = False ):
34373427 type : Required [Literal ['arguments' ]]
34383428 arguments_schema : Required [list [ArgumentsParameter ]]
3439- populate_by_name : bool
3429+ validate_by_name : bool
3430+ validate_by_alias : bool
34403431 var_args_schema : CoreSchema
34413432 var_kwargs_mode : VarKwargsMode
34423433 var_kwargs_schema : CoreSchema
@@ -3448,7 +3439,8 @@ class ArgumentsSchema(TypedDict, total=False):
34483439def arguments_schema (
34493440 arguments : list [ArgumentsParameter ],
34503441 * ,
3451- populate_by_name : bool | None = None ,
3442+ validate_by_name : bool | None = None ,
3443+ validate_by_alias : bool | None = None ,
34523444 var_args_schema : CoreSchema | None = None ,
34533445 var_kwargs_mode : VarKwargsMode | None = None ,
34543446 var_kwargs_schema : CoreSchema | None = None ,
@@ -3475,7 +3467,8 @@ def arguments_schema(
34753467
34763468 Args:
34773469 arguments: The arguments to use for the arguments schema
3478- populate_by_name: Whether to populate by name
3470+ validate_by_name: Whether to populate by argument names, defaults to False.
3471+ validate_by_alias: Whether to populate by argument aliases, defaults to True.
34793472 var_args_schema: The variable args schema to use for the arguments schema
34803473 var_kwargs_mode: The validation mode to use for variadic keyword arguments. If `'uniform'`, every value of the
34813474 keyword arguments will be validated against the `var_kwargs_schema` schema. If `'unpacked-typed-dict'`,
@@ -3488,7 +3481,8 @@ def arguments_schema(
34883481 return _dict_not_none (
34893482 type = 'arguments' ,
34903483 arguments_schema = arguments ,
3491- populate_by_name = populate_by_name ,
3484+ validate_by_name = validate_by_name ,
3485+ validate_by_alias = validate_by_alias ,
34923486 var_args_schema = var_args_schema ,
34933487 var_kwargs_mode = var_kwargs_mode ,
34943488 var_kwargs_schema = var_kwargs_schema ,
0 commit comments