Skip to content

Commit 2575e71

Browse files
authored
Update pydantic-core to latest version (pydantic#7277)
1 parent 427e9e6 commit 2575e71

File tree

9 files changed

+160
-160
lines changed

9 files changed

+160
-160
lines changed

docs/usage/types/custom.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ except ValidationError as exc:
124124
print(exc)
125125
"""
126126
1 validation error for list[int]
127-
List should have at most 10 items after validation, not 11 [type=too_long, input_value=[1, 1, 1, 1, 1, 1, 1, 1, ... 1, 1, 1, 1, 1, 1, 1, 1], input_type=list]
127+
List should have at most 10 items after validation, not 100 [type=too_long, input_value=[1, 1, 1, 1, 1, 1, 1, 1, ... 1, 1, 1, 1, 1, 1, 1, 1], input_type=list]
128128
"""
129129

130130

pdm.lock

Lines changed: 131 additions & 131 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pydantic/_internal/_core_utils.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ def handle_tuple_positional_schema(
262262
) -> core_schema.CoreSchema:
263263
schema = cast(core_schema.TuplePositionalSchema, schema)
264264
schema['items_schema'] = [self.walk(v, f) for v in schema['items_schema']]
265-
extra_schema = schema.get('extra_schema')
266-
if extra_schema is not None:
267-
schema['extra_schema'] = self.walk(extra_schema, f)
265+
extras_schema = schema.get('extras_schema')
266+
if extras_schema is not None:
267+
schema['extras_schema'] = self.walk(extras_schema, f)
268268
return schema
269269

270270
def handle_dict_schema(self, schema: core_schema.DictSchema, f: Walk) -> core_schema.CoreSchema:
@@ -314,9 +314,9 @@ def handle_json_or_python_schema(self, schema: core_schema.JsonOrPythonSchema, f
314314
return schema
315315

316316
def handle_model_fields_schema(self, schema: core_schema.ModelFieldsSchema, f: Walk) -> core_schema.CoreSchema:
317-
extra_validator = schema.get('extra_validator')
318-
if extra_validator is not None:
319-
schema['extra_validator'] = self.walk(extra_validator, f)
317+
extras_schema = schema.get('extras_schema')
318+
if extras_schema is not None:
319+
schema['extras_schema'] = self.walk(extras_schema, f)
320320
replaced_fields: dict[str, core_schema.ModelField] = {}
321321
replaced_computed_fields: list[core_schema.ComputedField] = []
322322
for computed_field in schema.get('computed_fields', ()):
@@ -333,9 +333,9 @@ def handle_model_fields_schema(self, schema: core_schema.ModelFieldsSchema, f: W
333333
return schema
334334

335335
def handle_typed_dict_schema(self, schema: core_schema.TypedDictSchema, f: Walk) -> core_schema.CoreSchema:
336-
extra_validator = schema.get('extra_validator')
337-
if extra_validator is not None:
338-
schema['extra_validator'] = self.walk(extra_validator, f)
336+
extras_schema = schema.get('extras_schema')
337+
if extras_schema is not None:
338+
schema['extras_schema'] = self.walk(extras_schema, f)
339339
replaced_computed_fields: list[core_schema.ComputedField] = []
340340
for computed_field in schema.get('computed_fields', ()):
341341
replaced_field = computed_field.copy()

pydantic/_internal/_generate_schema.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ def _model_schema(self, cls: type[BaseModel]) -> core_schema.CoreSchema:
481481

482482
model_validators = decorators.model_validators.values()
483483

484-
extra_validator = None
484+
extras_schema = None
485485
if core_config.get('extra_fields_behavior') == 'allow':
486486
for tp in (cls, *cls.__mro__):
487487
extras_annotation = cls.__annotations__.get('__pydantic_extra__', None)
@@ -496,7 +496,7 @@ def _model_schema(self, cls: type[BaseModel]) -> core_schema.CoreSchema:
496496
required=True,
497497
)[1]
498498
if extra_items_type is not Any:
499-
extra_validator = self.generate_schema(extra_items_type)
499+
extras_schema = self.generate_schema(extra_items_type)
500500
break
501501

502502
with self._config_wrapper_stack.push(config_wrapper):
@@ -522,7 +522,7 @@ def _model_schema(self, cls: type[BaseModel]) -> core_schema.CoreSchema:
522522
self._computed_field_schema(d, decorators.field_serializers)
523523
for d in computed_fields.values()
524524
],
525-
extra_validator=extra_validator,
525+
extras_schema=extras_schema,
526526
model_name=cls.__name__,
527527
)
528528
inner_schema = apply_validators(fields_schema, decorators.root_validators.values(), None)

pydantic/json_schema.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,8 @@ def tuple_positional_schema(self, schema: core_schema.TuplePositionalSchema) ->
795795
prefixItems = [self.generate_inner(item) for item in schema['items_schema']]
796796
if prefixItems:
797797
json_schema['prefixItems'] = prefixItems
798-
if 'extra_schema' in schema:
799-
json_schema['items'] = self.generate_inner(schema['extra_schema'])
798+
if 'extras_schema' in schema:
799+
json_schema['items'] = self.generate_inner(schema['extras_schema'])
800800
else:
801801
json_schema['maxItems'] = len(schema['items_schema'])
802802
self.update_with_validations(json_schema, schema, self.ValidationsMapping.array)
@@ -1383,10 +1383,10 @@ def model_fields_schema(self, schema: core_schema.ModelFieldsSchema) -> JsonSche
13831383
if self.mode == 'serialization':
13841384
named_required_fields.extend(self._name_required_computed_fields(schema.get('computed_fields', [])))
13851385
json_schema = self._named_required_fields_schema(named_required_fields)
1386-
extra_validator = schema.get('extra_validator', None)
1387-
if extra_validator is not None:
1386+
extras_schema = schema.get('extras_schema', None)
1387+
if extras_schema is not None:
13881388
schema_to_update = self.resolve_schema_to_update(json_schema)
1389-
schema_to_update['additionalProperties'] = self.generate_inner(extra_validator)
1389+
schema_to_update['additionalProperties'] = self.generate_inner(extras_schema)
13901390
return json_schema
13911391

13921392
def field_is_present(self, field: CoreSchemaField) -> bool:

pydantic/v1/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ def __new__(mcs, name, bases, namespace, **kwargs): # noqa C901
161161

162162
for f in fields.values():
163163
f.set_config(config)
164-
extra_validators = vg.get_validators(f.name)
165-
if extra_validators:
166-
f.class_validators.update(extra_validators)
164+
extras_schemas = vg.get_validators(f.name)
165+
if extras_schemas:
166+
f.class_validators.update(extras_schemas)
167167
# re-run prepare to add extra validators
168168
f.populate_validators()
169169

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ requires-python = '>=3.7'
6161
dependencies = [
6262
'typing-extensions>=4.6.1',
6363
'annotated-types>=0.4.0',
64-
"pydantic-core==2.6.3",
64+
"pydantic-core==2.7.0",
6565
]
6666
dynamic = ['version', 'readme']
6767

tests/test_json_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2475,7 +2475,7 @@ class MyTuple(Tuple[int, str]):
24752475
@classmethod
24762476
def __get_pydantic_core_schema__(cls, _source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema:
24772477
return core_schema.tuple_positional_schema(
2478-
[core_schema.int_schema(), core_schema.str_schema()], extra_schema=core_schema.int_schema()
2478+
[core_schema.int_schema(), core_schema.str_schema()], extras_schema=core_schema.int_schema()
24792479
)
24802480

24812481
class Model(BaseModel):

tests/test_utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,8 @@ def test_camel2snake(value: str, result: str) -> None:
547547
(
548548
pytest.param({}, {}, id='Positional tuple without extra_schema'),
549549
pytest.param(
550-
{'extra_schema': core_schema.float_schema()},
551-
{'extra_schema': {'type': 'str'}},
550+
{'extras_schema': core_schema.float_schema()},
551+
{'extras_schema': {'type': 'str'}},
552552
id='Positional tuple with extra_schema',
553553
),
554554
),
@@ -575,8 +575,8 @@ def walk(s, recurse):
575575
(
576576
pytest.param({}, {}, id='Model fields without extra_validator'),
577577
pytest.param(
578-
{'extra_validator': core_schema.float_schema()},
579-
{'extra_validator': {'type': 'str'}},
578+
{'extras_schema': core_schema.float_schema()},
579+
{'extras_schema': {'type': 'str'}},
580580
id='Model fields with extra_validator',
581581
),
582582
),
@@ -608,8 +608,8 @@ def walk(s, recurse):
608608
(
609609
pytest.param({}, {}, id='Typeddict without extra_validator'),
610610
pytest.param(
611-
{'extra_validator': core_schema.float_schema()},
612-
{'extra_validator': {'type': 'str'}},
611+
{'extras_schema': core_schema.float_schema()},
612+
{'extras_schema': {'type': 'str'}},
613613
id='Typeddict with extra_validator',
614614
),
615615
),

0 commit comments

Comments
 (0)