diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5049910..f1706e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 66198cf..e053abf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Changelog ========= +2.19.0 (2026-02-14) +------------------- + +- feat: python 3.14 support added. +- fix: wrapped does not inherit ns, nsmap from inner entity. + 2.18.0 (2025-10-11) ------------------- diff --git a/pydantic_xml/compat.py b/pydantic_xml/compat.py index 57c88e8..4809050 100644 --- a/pydantic_xml/compat.py +++ b/pydantic_xml/compat.py @@ -11,6 +11,6 @@ def merge_field_infos(*field_infos: pd.fields.FieldInfo) -> pd.fields.FieldInfo: if PYDANTIC_VERSION >= (2, 12, 0): - return pd.fields.FieldInfo._construct(field_infos) # type: ignore[attr-defined] + return pd.fields.FieldInfo._construct(list(field_infos)) else: return pd.fields.FieldInfo.merge_field_infos(*field_infos) diff --git a/pydantic_xml/fields.py b/pydantic_xml/fields.py index c0cabd3..8da86ae 100644 --- a/pydantic_xml/fields.py +++ b/pydantic_xml/fields.py @@ -1,3 +1,4 @@ +import copy import dataclasses as dc import typing from typing import Any, Callable, Dict, Optional, Union @@ -196,9 +197,13 @@ def wrapped( field_info = pd.fields.FieldInfo(default=default, default_factory=default_factory, **kwargs) else: wrapped_entity_info = extract_field_xml_entity_info(entity) + field_info = copy.deepcopy(entity) + # wrapped must not inherit ns, nsmap from inner entity + field_info.metadata = [item for item in field_info.metadata if not isinstance(item, XmlEntityInfo)] + field_info = compat.merge_field_infos( pd.fields.FieldInfo(default=default, default_factory=default_factory, **kwargs), - entity, + field_info, ) field_info.metadata.append( diff --git a/pyproject.toml b/pyproject.toml index 72ee1fc..bd889bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pydantic-xml" -version = "2.18.0" +version = "2.19.0" description = "pydantic xml extension" authors = ["Dmitry Pershin "] license = "Unlicense" @@ -29,6 +29,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Typing :: Typed", ] @@ -54,7 +55,7 @@ mypy = "^1.4.1" pre-commit = "~3.2.0" pytest = "^7.4.0" pytest-cov = "^4.1.0" -xmldiff = "2.5" +xmldiff = "^2.7.0" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/tests/helpers.py b/tests/helpers.py index 4eb9298..2516e68 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -14,6 +14,7 @@ def assert_xml_equal( right: Union[str, bytes], *, ignore_comments: bool = True, + ignore_namespace: bool = True, pretty: bool = True, **kwargs, ): @@ -21,6 +22,9 @@ def assert_xml_equal( if ignore_comments: diffs = list(filter(lambda diff: not isinstance(diff, xmldiff.actions.InsertComment), diffs)) + if ignore_namespace: + ns_actions = (xmldiff.actions.InsertNamespace, xmldiff.actions.DeleteNamespace) + diffs = list(filter(lambda diff: not isinstance(diff, ns_actions), diffs)) if diffs: if pretty: diff --git a/tests/test_namespaces.py b/tests/test_namespaces.py index d9d0b0b..264a327 100644 --- a/tests/test_namespaces.py +++ b/tests/test_namespaces.py @@ -345,7 +345,7 @@ class TestModel(BaseTestModel, tag='model', ns='tst', nsmap={'tst': 'http://test pass xml1 = ''' - + value '''