Skip to content

Commit

Permalink
Merge pull request #184 from dapper91/dev
Browse files Browse the repository at this point in the history
- PEP-681 (Data Class Transforms) support added.
- pydantic 2.7 enum type support added.
  • Loading branch information
dapper91 committed Apr 12, 2024
2 parents ce3d709 + aea6311 commit 188d61a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default_stages:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: check-toml
Expand All @@ -25,25 +25,25 @@ repos:
args:
- --fix=no
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.0.0
rev: v3.1.0
hooks:
- id: add-trailing-comma
stages:
- commit
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v2.0.2
rev: v2.0.4
hooks:
- id: autopep8
stages:
- commit
args:
- --diff
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 7.0.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
name: fix import order
Expand All @@ -63,7 +63,7 @@ repos:
- --multi-line=9
- --project=pydantic_xml
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
rev: v1.9.0
hooks:
- id: mypy
stages:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

2.9.1 (2024-04-12)
------------------

- PEP-681 (Data Class Transforms) support added. See https://github.com/dapper91/pydantic-xml/pull/178.
- pydantic 2.7 enum type support added. See https://github.com/dapper91/pydantic-xml/issues/182


2.9.0 (2024-02-03)
------------------

Expand Down
3 changes: 3 additions & 0 deletions pydantic_xml/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pydantic as pd
import pydantic_core as pdc
import typing_extensions as te
from pydantic import BaseModel, RootModel
from pydantic._internal._model_construction import ModelMetaclass # noqa
from pydantic.root_model import _RootModelMetaclass as RootModelMetaclass # noqa
Expand Down Expand Up @@ -249,6 +250,7 @@ def wrapped(
)


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


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

Expand Down
1 change: 1 addition & 0 deletions pydantic_xml/serializers/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class SchemaTypeFamily(IntEnum):
'float': SchemaTypeFamily.PRIMITIVE,
'str': SchemaTypeFamily.PRIMITIVE,
'bytes': SchemaTypeFamily.PRIMITIVE,
'enum': SchemaTypeFamily.PRIMITIVE,
'date': SchemaTypeFamily.PRIMITIVE,
'time': SchemaTypeFamily.PRIMITIVE,
'datetime': SchemaTypeFamily.PRIMITIVE,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pydantic-xml"
version = "2.9.0"
version = "2.9.1"
description = "pydantic xml extension"
authors = ["Dmitry Pershin <dapper1291@gmail.com>"]
license = "Unlicense"
Expand Down

0 comments on commit 188d61a

Please sign in to comment.