Skip to content

Commit 76e143a

Browse files
authored
Merge pull request #303 from dapper91/dev
- feat: python 3.14 support added. - fix: wrapped does not inherit ns, nsmap from inner entity.
2 parents 5fb6756 + d15b2b4 commit 76e143a

File tree

7 files changed

+22
-6
lines changed

7 files changed

+22
-6
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
17+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
1818
steps:
1919
- uses: actions/checkout@v2
2020
- name: Set up Python ${{ matrix.python-version }}

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
2.19.0 (2026-02-14)
5+
-------------------
6+
7+
- feat: python 3.14 support added.
8+
- fix: wrapped does not inherit ns, nsmap from inner entity.
9+
410

511
2.18.0 (2025-10-11)
612
-------------------

pydantic_xml/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
def merge_field_infos(*field_infos: pd.fields.FieldInfo) -> pd.fields.FieldInfo:
1313
if PYDANTIC_VERSION >= (2, 12, 0):
14-
return pd.fields.FieldInfo._construct(field_infos) # type: ignore[attr-defined]
14+
return pd.fields.FieldInfo._construct(list(field_infos))
1515
else:
1616
return pd.fields.FieldInfo.merge_field_infos(*field_infos)

pydantic_xml/fields.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import copy
12
import dataclasses as dc
23
import typing
34
from typing import Any, Callable, Dict, Optional, Union
@@ -196,9 +197,13 @@ def wrapped(
196197
field_info = pd.fields.FieldInfo(default=default, default_factory=default_factory, **kwargs)
197198
else:
198199
wrapped_entity_info = extract_field_xml_entity_info(entity)
200+
field_info = copy.deepcopy(entity)
201+
# wrapped must not inherit ns, nsmap from inner entity
202+
field_info.metadata = [item for item in field_info.metadata if not isinstance(item, XmlEntityInfo)]
203+
199204
field_info = compat.merge_field_infos(
200205
pd.fields.FieldInfo(default=default, default_factory=default_factory, **kwargs),
201-
entity,
206+
field_info,
202207
)
203208

204209
field_info.metadata.append(

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pydantic-xml"
3-
version = "2.18.0"
3+
version = "2.19.0"
44
description = "pydantic xml extension"
55
authors = ["Dmitry Pershin <dapper1291@gmail.com>"]
66
license = "Unlicense"
@@ -29,6 +29,7 @@ classifiers = [
2929
"Programming Language :: Python :: 3.11",
3030
"Programming Language :: Python :: 3.12",
3131
"Programming Language :: Python :: 3.13",
32+
"Programming Language :: Python :: 3.14",
3233
"Typing :: Typed",
3334
]
3435

@@ -54,7 +55,7 @@ mypy = "^1.4.1"
5455
pre-commit = "~3.2.0"
5556
pytest = "^7.4.0"
5657
pytest-cov = "^4.1.0"
57-
xmldiff = "2.5"
58+
xmldiff = "^2.7.0"
5859

5960
[build-system]
6061
requires = ["poetry-core>=1.0.0"]

tests/helpers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ def assert_xml_equal(
1414
right: Union[str, bytes],
1515
*,
1616
ignore_comments: bool = True,
17+
ignore_namespace: bool = True,
1718
pretty: bool = True,
1819
**kwargs,
1920
):
2021
diffs = xmldiff.main.diff_texts(left, right, **kwargs)
2122

2223
if ignore_comments:
2324
diffs = list(filter(lambda diff: not isinstance(diff, xmldiff.actions.InsertComment), diffs))
25+
if ignore_namespace:
26+
ns_actions = (xmldiff.actions.InsertNamespace, xmldiff.actions.DeleteNamespace)
27+
diffs = list(filter(lambda diff: not isinstance(diff, ns_actions), diffs))
2428

2529
if diffs:
2630
if pretty:

tests/test_namespaces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ class TestModel(BaseTestModel, tag='model', ns='tst', nsmap={'tst': 'http://test
345345
pass
346346

347347
xml1 = '''
348-
<tst:model xmlns:tst="http://test1.org" attr1="1">
348+
<tst:model xmlns:bs="http://base.org" xmlns:tst="http://test1.org" attr1="1">
349349
<tst:element1>value</tst:element1>
350350
</tst:model>
351351
'''

0 commit comments

Comments
 (0)