Skip to content

Commit 188d61a

Browse files
authored
Merge pull request #184 from dapper91/dev
- PEP-681 (Data Class Transforms) support added. - pydantic 2.7 enum type support added.
2 parents ce3d709 + aea6311 commit 188d61a

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ default_stages:
44

55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.4.0
7+
rev: v4.5.0
88
hooks:
99
- id: check-yaml
1010
- id: check-toml
@@ -25,25 +25,25 @@ repos:
2525
args:
2626
- --fix=no
2727
- repo: https://github.com/asottile/add-trailing-comma
28-
rev: v3.0.0
28+
rev: v3.1.0
2929
hooks:
3030
- id: add-trailing-comma
3131
stages:
3232
- commit
3333
- repo: https://github.com/pre-commit/mirrors-autopep8
34-
rev: v2.0.2
34+
rev: v2.0.4
3535
hooks:
3636
- id: autopep8
3737
stages:
3838
- commit
3939
args:
4040
- --diff
4141
- repo: https://github.com/pycqa/flake8
42-
rev: 6.0.0
42+
rev: 7.0.0
4343
hooks:
4444
- id: flake8
4545
- repo: https://github.com/pycqa/isort
46-
rev: 5.12.0
46+
rev: 5.13.2
4747
hooks:
4848
- id: isort
4949
name: fix import order
@@ -63,7 +63,7 @@ repos:
6363
- --multi-line=9
6464
- --project=pydantic_xml
6565
- repo: https://github.com/pre-commit/mirrors-mypy
66-
rev: v1.4.1
66+
rev: v1.9.0
6767
hooks:
6868
- id: mypy
6969
stages:

CHANGELOG.rst

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

4+
2.9.1 (2024-04-12)
5+
------------------
6+
7+
- PEP-681 (Data Class Transforms) support added. See https://github.com/dapper91/pydantic-xml/pull/178.
8+
- pydantic 2.7 enum type support added. See https://github.com/dapper91/pydantic-xml/issues/182
9+
10+
411
2.9.0 (2024-02-03)
512
------------------
613

pydantic_xml/model.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import pydantic as pd
66
import pydantic_core as pdc
7+
import typing_extensions as te
78
from pydantic import BaseModel, RootModel
89
from pydantic._internal._model_construction import ModelMetaclass # noqa
910
from pydantic.root_model import _RootModelMetaclass as RootModelMetaclass # noqa
@@ -249,6 +250,7 @@ def wrapped(
249250
)
250251

251252

253+
@te.dataclass_transform(kw_only_default=True, field_specifiers=(attr, element, wrapped, pd.Field))
252254
class XmlModelMeta(ModelMetaclass):
253255
"""
254256
Xml model metaclass.
@@ -434,6 +436,7 @@ def to_xml(self, *, skip_empty: bool = False, **kwargs: Any) -> Union[str, bytes
434436
return etree.tostring(self.to_xml_tree(skip_empty=skip_empty), **kwargs)
435437

436438

439+
@te.dataclass_transform(kw_only_default=True, field_specifiers=(attr, element, wrapped, pd.Field))
437440
class RootXmlModelMeta(XmlModelMeta, RootModelMetaclass):
438441
pass
439442

pydantic_xml/serializers/serializer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class SchemaTypeFamily(IntEnum):
4848
'float': SchemaTypeFamily.PRIMITIVE,
4949
'str': SchemaTypeFamily.PRIMITIVE,
5050
'bytes': SchemaTypeFamily.PRIMITIVE,
51+
'enum': SchemaTypeFamily.PRIMITIVE,
5152
'date': SchemaTypeFamily.PRIMITIVE,
5253
'time': SchemaTypeFamily.PRIMITIVE,
5354
'datetime': SchemaTypeFamily.PRIMITIVE,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pydantic-xml"
3-
version = "2.9.0"
3+
version = "2.9.1"
44
description = "pydantic xml extension"
55
authors = ["Dmitry Pershin <dapper1291@gmail.com>"]
66
license = "Unlicense"

0 commit comments

Comments
 (0)