msgspec-xml 0.3.0__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/PKG-INFO +2 -2
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/msgspec_xml/__init__.py +1 -1
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/msgspec_xml/introspection.py +6 -2
- msgspec_xml-0.3.2/pylock.toml +835 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/pyproject.toml +8 -8
- msgspec_xml-0.3.2/tests/resources/test-05.xml +7 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/tests/test_roundtrip.py +15 -1
- msgspec_xml-0.3.2/uv.lock +740 -0
- msgspec_xml-0.3.0/pylock.toml +0 -793
- msgspec_xml-0.3.0/uv.lock +0 -697
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/.gitattributes +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/.gitignore +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/.pre-commit-config.yaml +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/LICENSE +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/README.md +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/msgspec_xml/decoder.py +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/msgspec_xml/encoder.py +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/msgspec_xml/metadata.py +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/pdm.toml +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/renovate.json +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/tests/__init__.py +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/tests/resources/test-01.xml +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/tests/resources/test-02.xml +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/tests/resources/test-03.xml +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/tests/resources/test-04.xml +0 -0
- {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/tests/test_metadata.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: msgspec-xml
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: XML Serialization/Deserialization using msgspec
|
|
5
5
|
Project-URL: Homepage, https://pypi.org/project/msgspec-xml
|
|
6
6
|
Project-URL: Issues, https://codefloe.com/buriedincode/msgspec-xml/issues
|
|
@@ -24,6 +24,7 @@ class FieldType(Struct, frozen=True, kw_only=True):
|
|
|
24
24
|
type: Any
|
|
25
25
|
xml: XML
|
|
26
26
|
is_struct: bool = False
|
|
27
|
+
is_generic: bool = False
|
|
27
28
|
item: Optional["FieldType"] = None
|
|
28
29
|
|
|
29
30
|
|
|
@@ -35,6 +36,9 @@ def inspect_annotation(annotation: Any) -> FieldType: # noqa: ANN401
|
|
|
35
36
|
return FieldType(
|
|
36
37
|
type=annotation, xml=xml, item=inspect_annotation(annotation=item_annotation)
|
|
37
38
|
)
|
|
39
|
+
origin = get_origin(annotation)
|
|
40
|
+
if origin is not None and isinstance(origin, type) and issubclass(origin, Struct):
|
|
41
|
+
return FieldType(type=origin, xml=xml, is_struct=True, is_generic=True)
|
|
38
42
|
return FieldType(type=annotation, xml=xml, is_struct=is_struct_type(annotation))
|
|
39
43
|
|
|
40
44
|
|
|
@@ -60,7 +64,7 @@ def attribute_name(field: FieldInfo, info: FieldType, namespaces: dict[str, str]
|
|
|
60
64
|
def element_tag(field: FieldInfo, info: FieldType, namespaces: dict[str, str]) -> str:
|
|
61
65
|
if info.xml.tag:
|
|
62
66
|
name = info.xml.tag
|
|
63
|
-
elif info.is_struct:
|
|
67
|
+
elif info.is_struct and not info.is_generic:
|
|
64
68
|
name = class_tag(cls=info.type)
|
|
65
69
|
else:
|
|
66
70
|
name = field.encode_name
|
|
@@ -76,7 +80,7 @@ def item_tag(field: FieldInfo, info: FieldType, namespaces: dict[str, str]) -> s
|
|
|
76
80
|
name = item.xml.tag
|
|
77
81
|
elif info.xml.tag:
|
|
78
82
|
name = info.xml.tag
|
|
79
|
-
elif item.is_struct:
|
|
83
|
+
elif item.is_struct and not item.is_generic:
|
|
80
84
|
name = class_tag(cls=item.type)
|
|
81
85
|
else:
|
|
82
86
|
name = field.encode_name
|