Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Sep 2023 20:53:17 GMT
From:      Po-Chuan Hsieh <sunpoet@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: cbbc841775b4 - main - devel/py-pydantic2: Allow build with py-pydantic-core 2.7.0
Message-ID:  <202309062053.386KrHLb019984@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by sunpoet:

URL: https://cgit.FreeBSD.org/ports/commit/?id=cbbc841775b458ea8c654810d56de5fe2d96cd29

commit cbbc841775b458ea8c654810d56de5fe2d96cd29
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2023-09-06 20:49:44 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2023-09-06 20:49:44 +0000

    devel/py-pydantic2: Allow build with py-pydantic-core 2.7.0
    
    - Bump PORTREVISION for package change
    
    Obtained from:  https://github.com/pydantic/pydantic/commit/2575e71894a32dc615f9fa7a94ff37bb604a48a8
---
 devel/py-pydantic2/Makefile                  |   3 +-
 devel/py-pydantic2/files/patch-pydantic-core | 171 +++++++++++++++++++++++++++
 2 files changed, 173 insertions(+), 1 deletion(-)

diff --git a/devel/py-pydantic2/Makefile b/devel/py-pydantic2/Makefile
index 09227642fc44..8bf5552b697f 100644
--- a/devel/py-pydantic2/Makefile
+++ b/devel/py-pydantic2/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	pydantic
 PORTVERSION=	2.3.0
+PORTREVISION=	1
 CATEGORIES=	devel python
 MASTER_SITES=	PYPI
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
@@ -16,7 +17,7 @@ LICENSE_FILE=	${WRKSRC}/LICENSE
 BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}hatch-fancy-pypi-readme>=22.5.0:devel/py-hatch-fancy-pypi-readme@${PY_FLAVOR} \
 		${PYTHON_PKGNAMEPREFIX}hatchling>=0:devel/py-hatchling@${PY_FLAVOR}
 RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}annotated-types>=0.4.0:devel/py-annotated-types@${PY_FLAVOR} \
-		${PYTHON_PKGNAMEPREFIX}pydantic-core>=2.6.3<2.6.3_99:devel/py-pydantic-core@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pydantic-core>=2.7.0<2.7.0_99:devel/py-pydantic-core@${PY_FLAVOR} \
 		${PYTHON_PKGNAMEPREFIX}typing-extensions>=4.6.1:devel/py-typing-extensions@${PY_FLAVOR}
 
 USES=		python
diff --git a/devel/py-pydantic2/files/patch-pydantic-core b/devel/py-pydantic2/files/patch-pydantic-core
new file mode 100644
index 000000000000..79f89fd3a010
--- /dev/null
+++ b/devel/py-pydantic2/files/patch-pydantic-core
@@ -0,0 +1,171 @@
+Obtained from:	https://github.com/pydantic/pydantic/commit/2575e71894a32dc615f9fa7a94ff37bb604a48a8
+
+--- pydantic/_internal/_core_utils.py.orig	2020-02-02 00:00:00 UTC
++++ pydantic/_internal/_core_utils.py
+@@ -262,9 +262,9 @@ class _WalkCoreSchema:
+     ) -> core_schema.CoreSchema:
+         schema = cast(core_schema.TuplePositionalSchema, schema)
+         schema['items_schema'] = [self.walk(v, f) for v in schema['items_schema']]
+-        extra_schema = schema.get('extra_schema')
+-        if extra_schema is not None:
+-            schema['extra_schema'] = self.walk(extra_schema, f)
++        extras_schema = schema.get('extras_schema')
++        if extras_schema is not None:
++            schema['extras_schema'] = self.walk(extras_schema, f)
+         return schema
+ 
+     def handle_dict_schema(self, schema: core_schema.DictSchema, f: Walk) -> core_schema.CoreSchema:
+@@ -314,9 +314,9 @@ class _WalkCoreSchema:
+         return schema
+ 
+     def handle_model_fields_schema(self, schema: core_schema.ModelFieldsSchema, f: Walk) -> core_schema.CoreSchema:
+-        extra_validator = schema.get('extra_validator')
+-        if extra_validator is not None:
+-            schema['extra_validator'] = self.walk(extra_validator, f)
++        extras_schema = schema.get('extras_schema')
++        if extras_schema is not None:
++            schema['extras_schema'] = self.walk(extras_schema, f)
+         replaced_fields: dict[str, core_schema.ModelField] = {}
+         replaced_computed_fields: list[core_schema.ComputedField] = []
+         for computed_field in schema.get('computed_fields', ()):
+@@ -333,9 +333,9 @@ class _WalkCoreSchema:
+         return schema
+ 
+     def handle_typed_dict_schema(self, schema: core_schema.TypedDictSchema, f: Walk) -> core_schema.CoreSchema:
+-        extra_validator = schema.get('extra_validator')
+-        if extra_validator is not None:
+-            schema['extra_validator'] = self.walk(extra_validator, f)
++        extras_schema = schema.get('extras_schema')
++        if extras_schema is not None:
++            schema['extras_schema'] = self.walk(extras_schema, f)
+         replaced_computed_fields: list[core_schema.ComputedField] = []
+         for computed_field in schema.get('computed_fields', ()):
+             replaced_field = computed_field.copy()
+--- pydantic/_internal/_generate_schema.py.orig	2020-02-02 00:00:00 UTC
++++ pydantic/_internal/_generate_schema.py
+@@ -480,7 +480,7 @@ class GenerateSchema:
+ 
+             model_validators = decorators.model_validators.values()
+ 
+-            extra_validator = None
++            extras_schema = None
+             if core_config.get('extra_fields_behavior') == 'allow':
+                 for tp in (cls, *cls.__mro__):
+                     extras_annotation = cls.__annotations__.get('__pydantic_extra__', None)
+@@ -495,7 +495,7 @@ class GenerateSchema:
+                             required=True,
+                         )[1]
+                         if extra_items_type is not Any:
+-                            extra_validator = self.generate_schema(extra_items_type)
++                            extras_schema = self.generate_schema(extra_items_type)
+                             break
+ 
+             with self._config_wrapper_stack.push(config_wrapper):
+@@ -521,7 +521,7 @@ class GenerateSchema:
+                             self._computed_field_schema(d, decorators.field_serializers)
+                             for d in computed_fields.values()
+                         ],
+-                        extra_validator=extra_validator,
++                        extras_schema=extras_schema,
+                         model_name=cls.__name__,
+                     )
+                     inner_schema = apply_validators(fields_schema, decorators.root_validators.values(), None)
+--- pydantic/json_schema.py.orig	2020-02-02 00:00:00 UTC
++++ pydantic/json_schema.py
+@@ -795,8 +795,8 @@ class GenerateJsonSchema:
+         prefixItems = [self.generate_inner(item) for item in schema['items_schema']]
+         if prefixItems:
+             json_schema['prefixItems'] = prefixItems
+-        if 'extra_schema' in schema:
+-            json_schema['items'] = self.generate_inner(schema['extra_schema'])
++        if 'extras_schema' in schema:
++            json_schema['items'] = self.generate_inner(schema['extras_schema'])
+         else:
+             json_schema['maxItems'] = len(schema['items_schema'])
+         self.update_with_validations(json_schema, schema, self.ValidationsMapping.array)
+@@ -1383,10 +1383,10 @@ class GenerateJsonSchema:
+         if self.mode == 'serialization':
+             named_required_fields.extend(self._name_required_computed_fields(schema.get('computed_fields', [])))
+         json_schema = self._named_required_fields_schema(named_required_fields)
+-        extra_validator = schema.get('extra_validator', None)
+-        if extra_validator is not None:
++        extras_schema = schema.get('extras_schema', None)
++        if extras_schema is not None:
+             schema_to_update = self.resolve_schema_to_update(json_schema)
+-            schema_to_update['additionalProperties'] = self.generate_inner(extra_validator)
++            schema_to_update['additionalProperties'] = self.generate_inner(extras_schema)
+         return json_schema
+ 
+     def field_is_present(self, field: CoreSchemaField) -> bool:
+--- pydantic/v1/main.py.orig	2020-02-02 00:00:00 UTC
++++ pydantic/v1/main.py
+@@ -161,9 +161,9 @@ class ModelMetaclass(ABCMeta):
+ 
+         for f in fields.values():
+             f.set_config(config)
+-            extra_validators = vg.get_validators(f.name)
+-            if extra_validators:
+-                f.class_validators.update(extra_validators)
++            extras_schemas = vg.get_validators(f.name)
++            if extras_schemas:
++                f.class_validators.update(extras_schemas)
+                 # re-run prepare to add extra validators
+                 f.populate_validators()
+ 
+--- pyproject.toml.orig	2020-02-02 00:00:00 UTC
++++ pyproject.toml
+@@ -61,7 +61,7 @@ requires-python = '>=3.7'
+ dependencies = [
+     'typing-extensions>=4.6.1',
+     'annotated-types>=0.4.0',
+-    "pydantic-core==2.6.3",
++    "pydantic-core==2.7.0",
+ ]
+ dynamic = ['version', 'readme']
+ 
+--- tests/test_json_schema.py.orig	2020-02-02 00:00:00 UTC
++++ tests/test_json_schema.py
+@@ -2475,7 +2475,7 @@ def test_tuple_with_extra_schema():
+         @classmethod
+         def __get_pydantic_core_schema__(cls, _source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema:
+             return core_schema.tuple_positional_schema(
+-                [core_schema.int_schema(), core_schema.str_schema()], extra_schema=core_schema.int_schema()
++                [core_schema.int_schema(), core_schema.str_schema()], extras_schema=core_schema.int_schema()
+             )
+ 
+     class Model(BaseModel):
+--- tests/test_utils.py.orig	2020-02-02 00:00:00 UTC
++++ tests/test_utils.py
+@@ -547,8 +547,8 @@ def test_camel2snake(value: str, result: str) -> None:
+     (
+         pytest.param({}, {}, id='Positional tuple without extra_schema'),
+         pytest.param(
+-            {'extra_schema': core_schema.float_schema()},
+-            {'extra_schema': {'type': 'str'}},
++            {'extras_schema': core_schema.float_schema()},
++            {'extras_schema': {'type': 'str'}},
+             id='Positional tuple with extra_schema',
+         ),
+     ),
+@@ -575,8 +575,8 @@ def test_handle_tuple_positional_schema(params, expect
+     (
+         pytest.param({}, {}, id='Model fields without extra_validator'),
+         pytest.param(
+-            {'extra_validator': core_schema.float_schema()},
+-            {'extra_validator': {'type': 'str'}},
++            {'extras_schema': core_schema.float_schema()},
++            {'extras_schema': {'type': 'str'}},
+             id='Model fields with extra_validator',
+         ),
+     ),
+@@ -608,8 +608,8 @@ def test_handle_model_fields_schema(params, expected_e
+     (
+         pytest.param({}, {}, id='Typeddict without extra_validator'),
+         pytest.param(
+-            {'extra_validator': core_schema.float_schema()},
+-            {'extra_validator': {'type': 'str'}},
++            {'extras_schema': core_schema.float_schema()},
++            {'extras_schema': {'type': 'str'}},
+             id='Typeddict with extra_validator',
+         ),
+     ),



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202309062053.386KrHLb019984>