@@ -176,7 +176,6 @@ class FieldInfo(_repr.Representation):
176
176
'init_var' ,
177
177
'kw_only' ,
178
178
'metadata' ,
179
- '_attributes_set' ,
180
179
)
181
180
182
181
# used to convert kwargs to metadata/constraints,
@@ -205,17 +204,12 @@ def __init__(self, **kwargs: Unpack[_FieldInfoInputs]) -> None:
205
204
206
205
See the signature of `pydantic.fields.Field` for more details about the expected arguments.
207
206
"""
208
- self ._attributes_set = {k : v for k , v in kwargs .items () if v is not _Unset }
209
207
kwargs = {k : _DefaultValues .get (k ) if v is _Unset else v for k , v in kwargs .items ()} # type: ignore
210
208
self .annotation = kwargs .get ('annotation' )
211
209
212
210
default = kwargs .pop ('default' , PydanticUndefined )
213
211
if default is Ellipsis :
214
212
self .default = PydanticUndefined
215
- # Also remove it from the attributes set, otherwise
216
- # `GenerateSchema._common_field_schema` mistakenly
217
- # uses it:
218
- self ._attributes_set .pop ('default' , None )
219
213
else :
220
214
self .default = default
221
215
@@ -455,7 +449,6 @@ def merge_field_infos(*field_infos: FieldInfo, **overrides: Any) -> FieldInfo:
455
449
if len (field_infos ) == 1 :
456
450
# No merging necessary, but we still need to make a copy and apply the overrides
457
451
field_info = copy (field_infos [0 ])
458
- field_info ._attributes_set .update (overrides )
459
452
460
453
default_override = overrides .pop ('default' , PydanticUndefined )
461
454
if default_override is Ellipsis :
@@ -470,10 +463,8 @@ def merge_field_infos(*field_infos: FieldInfo, **overrides: Any) -> FieldInfo:
470
463
merged_field_info_kwargs : dict [str , Any ] = {}
471
464
metadata = {}
472
465
for field_info in field_infos :
473
- attributes_set = field_info ._attributes_set .copy ()
474
-
475
- try :
476
- json_schema_extra = attributes_set .pop ('json_schema_extra' )
466
+ json_schema_extra = field_info .json_schema_extra
467
+ if json_schema_extra is not None :
477
468
existing_json_schema_extra = merged_field_info_kwargs .get ('json_schema_extra' )
478
469
479
470
if existing_json_schema_extra is None :
@@ -494,11 +485,6 @@ def merge_field_infos(*field_infos: FieldInfo, **overrides: Any) -> FieldInfo:
494
485
elif callable (json_schema_extra ):
495
486
# if ever there's a case of a callable, we'll just keep the last json schema extra spec
496
487
merged_field_info_kwargs ['json_schema_extra' ] = json_schema_extra
497
- except KeyError :
498
- pass
499
-
500
- # later FieldInfo instances override everything except json_schema_extra from earlier FieldInfo instances
501
- merged_field_info_kwargs .update (attributes_set )
502
488
503
489
for x in field_info .metadata :
504
490
if not isinstance (x , FieldInfo ):
@@ -678,7 +664,7 @@ def __repr_args__(self) -> ReprArgs:
678
664
for s in self .__slots__ :
679
665
# TODO: properly make use of the protocol (https://rich.readthedocs.io/en/stable/pretty.html#rich-repr-protocol)
680
666
# By yielding a three-tuple:
681
- if s in ( '_attributes_set' , ' annotation') :
667
+ if s == ' annotation' :
682
668
continue
683
669
elif s == 'metadata' and not self .metadata :
684
670
continue
0 commit comments