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.
Files changed (26) hide show
  1. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/PKG-INFO +2 -2
  2. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/msgspec_xml/__init__.py +1 -1
  3. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/msgspec_xml/introspection.py +6 -2
  4. msgspec_xml-0.3.2/pylock.toml +835 -0
  5. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/pyproject.toml +8 -8
  6. msgspec_xml-0.3.2/tests/resources/test-05.xml +7 -0
  7. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/tests/test_roundtrip.py +15 -1
  8. msgspec_xml-0.3.2/uv.lock +740 -0
  9. msgspec_xml-0.3.0/pylock.toml +0 -793
  10. msgspec_xml-0.3.0/uv.lock +0 -697
  11. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/.gitattributes +0 -0
  12. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/.gitignore +0 -0
  13. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/.pre-commit-config.yaml +0 -0
  14. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/LICENSE +0 -0
  15. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/README.md +0 -0
  16. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/msgspec_xml/decoder.py +0 -0
  17. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/msgspec_xml/encoder.py +0 -0
  18. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/msgspec_xml/metadata.py +0 -0
  19. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/pdm.toml +0 -0
  20. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/renovate.json +0 -0
  21. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/tests/__init__.py +0 -0
  22. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/tests/resources/test-01.xml +0 -0
  23. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/tests/resources/test-02.xml +0 -0
  24. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/tests/resources/test-03.xml +0 -0
  25. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/tests/resources/test-04.xml +0 -0
  26. {msgspec_xml-0.3.0 → msgspec_xml-0.3.2}/tests/test_metadata.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: msgspec-xml
3
- Version: 0.3.0
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
@@ -9,7 +9,7 @@ __all__ = [
9
9
  "decode",
10
10
  "encode",
11
11
  ]
12
- __version__ = "0.3.0"
12
+ __version__ = "0.3.2"
13
13
 
14
14
  from msgspec_xml.decoder import Decoder, decode
15
15
  from msgspec_xml.encoder import Encoder, encode
@@ -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