polyxml 0.2.0__tar.gz → 0.3.0__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 (23) hide show
  1. {polyxml-0.2.0 → polyxml-0.3.0}/Cargo.lock +22 -43
  2. {polyxml-0.2.0 → polyxml-0.3.0}/Cargo.toml +1 -1
  3. {polyxml-0.2.0 → polyxml-0.3.0}/PKG-INFO +1 -1
  4. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-core/Cargo.toml +2 -2
  5. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-core/benches/core_benchmarks.rs +3 -1
  6. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-python/Cargo.toml +1 -2
  7. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-python/src/lib.rs +38 -54
  8. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-python/tests/test_polyxml.py +60 -1
  9. {polyxml-0.2.0 → polyxml-0.3.0}/pyproject.toml +1 -1
  10. {polyxml-0.2.0 → polyxml-0.3.0}/README.md +0 -0
  11. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-core/README.md +0 -0
  12. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-core/src/converters.rs +0 -0
  13. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-core/src/error.rs +0 -0
  14. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-core/src/lib.rs +0 -0
  15. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-core/src/parser.rs +0 -0
  16. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-core/src/schema.rs +0 -0
  17. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-core/src/serializer.rs +0 -0
  18. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-core/src/value.rs +0 -0
  19. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-core/tests/test_core.rs +0 -0
  20. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-core/tests/test_security.rs +0 -0
  21. {polyxml-0.2.0 → polyxml-0.3.0}/crates/polyxml-python/README.md +0 -0
  22. {polyxml-0.2.0 → polyxml-0.3.0}/python/polyxml/__init__.py +0 -0
  23. {polyxml-0.2.0 → polyxml-0.3.0}/python/polyxml/py.typed +0 -0
@@ -110,23 +110,20 @@ dependencies = [
110
110
 
111
111
  [[package]]
112
112
  name = "criterion"
113
- version = "0.5.1"
113
+ version = "0.7.0"
114
114
  source = "registry+https://github.com/rust-lang/crates.io-index"
115
- checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f"
115
+ checksum = "e1c047a62b0cc3e145fa84415a3191f628e980b194c2755aa12300a4e6cbd928"
116
116
  dependencies = [
117
117
  "anes",
118
118
  "cast",
119
119
  "ciborium",
120
120
  "clap",
121
121
  "criterion-plot",
122
- "is-terminal",
123
122
  "itertools",
124
123
  "num-traits",
125
- "once_cell",
126
124
  "oorandom",
127
125
  "regex",
128
126
  "serde",
129
- "serde_derive",
130
127
  "serde_json",
131
128
  "tinytemplate",
132
129
  "walkdir",
@@ -134,9 +131,9 @@ dependencies = [
134
131
 
135
132
  [[package]]
136
133
  name = "criterion-plot"
137
- version = "0.5.0"
134
+ version = "0.6.0"
138
135
  source = "registry+https://github.com/rust-lang/crates.io-index"
139
- checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
136
+ checksum = "9b1bcc0dc7dfae599d84ad0b1a55f80cde8af3725da8313b528da95ef783e338"
140
137
  dependencies = [
141
138
  "cast",
142
139
  "itertools",
@@ -187,12 +184,6 @@ version = "0.5.0"
187
184
  source = "registry+https://github.com/rust-lang/crates.io-index"
188
185
  checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
189
186
 
190
- [[package]]
191
- name = "hermit-abi"
192
- version = "0.5.3"
193
- source = "registry+https://github.com/rust-lang/crates.io-index"
194
- checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284"
195
-
196
187
  [[package]]
197
188
  name = "indoc"
198
189
  version = "2.0.7"
@@ -202,22 +193,11 @@ dependencies = [
202
193
  "rustversion",
203
194
  ]
204
195
 
205
- [[package]]
206
- name = "is-terminal"
207
- version = "0.4.17"
208
- source = "registry+https://github.com/rust-lang/crates.io-index"
209
- checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"
210
- dependencies = [
211
- "hermit-abi",
212
- "libc",
213
- "windows-sys",
214
- ]
215
-
216
196
  [[package]]
217
197
  name = "itertools"
218
- version = "0.10.5"
198
+ version = "0.13.0"
219
199
  source = "registry+https://github.com/rust-lang/crates.io-index"
220
- checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
200
+ checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
221
201
  dependencies = [
222
202
  "either",
223
203
  ]
@@ -396,7 +376,7 @@ checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e"
396
376
 
397
377
  [[package]]
398
378
  name = "polyxml"
399
- version = "0.2.0"
379
+ version = "0.3.0"
400
380
  dependencies = [
401
381
  "criterion",
402
382
  "lexical-core",
@@ -409,14 +389,14 @@ dependencies = [
409
389
 
410
390
  [[package]]
411
391
  name = "polyxml-c"
412
- version = "0.2.0"
392
+ version = "0.3.0"
413
393
  dependencies = [
414
394
  "polyxml",
415
395
  ]
416
396
 
417
397
  [[package]]
418
398
  name = "polyxml-js"
419
- version = "0.2.0"
399
+ version = "0.3.0"
420
400
  dependencies = [
421
401
  "napi",
422
402
  "napi-build",
@@ -426,12 +406,11 @@ dependencies = [
426
406
 
427
407
  [[package]]
428
408
  name = "polyxml-python"
429
- version = "0.2.0"
409
+ version = "0.3.0"
430
410
  dependencies = [
431
411
  "lexical-core",
432
412
  "polyxml",
433
413
  "pyo3",
434
- "quick-xml",
435
414
  "smallvec",
436
415
  ]
437
416
 
@@ -462,9 +441,9 @@ dependencies = [
462
441
 
463
442
  [[package]]
464
443
  name = "pyo3"
465
- version = "0.22.6"
444
+ version = "0.23.5"
466
445
  source = "registry+https://github.com/rust-lang/crates.io-index"
467
- checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884"
446
+ checksum = "7778bffd85cf38175ac1f545509665d0b9b92a198ca7941f131f85f7a4f9a872"
468
447
  dependencies = [
469
448
  "cfg-if",
470
449
  "indoc",
@@ -480,9 +459,9 @@ dependencies = [
480
459
 
481
460
  [[package]]
482
461
  name = "pyo3-build-config"
483
- version = "0.22.6"
462
+ version = "0.23.5"
484
463
  source = "registry+https://github.com/rust-lang/crates.io-index"
485
- checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38"
464
+ checksum = "94f6cbe86ef3bf18998d9df6e0f3fc1050a8c5efa409bf712e661a4366e010fb"
486
465
  dependencies = [
487
466
  "once_cell",
488
467
  "target-lexicon",
@@ -490,9 +469,9 @@ dependencies = [
490
469
 
491
470
  [[package]]
492
471
  name = "pyo3-ffi"
493
- version = "0.22.6"
472
+ version = "0.23.5"
494
473
  source = "registry+https://github.com/rust-lang/crates.io-index"
495
- checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636"
474
+ checksum = "e9f1b4c431c0bb1c8fb0a338709859eed0d030ff6daa34368d3b152a63dfdd8d"
496
475
  dependencies = [
497
476
  "libc",
498
477
  "pyo3-build-config",
@@ -500,9 +479,9 @@ dependencies = [
500
479
 
501
480
  [[package]]
502
481
  name = "pyo3-macros"
503
- version = "0.22.6"
482
+ version = "0.23.5"
504
483
  source = "registry+https://github.com/rust-lang/crates.io-index"
505
- checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453"
484
+ checksum = "fbc2201328f63c4710f68abdf653c89d8dbc2858b88c5d88b0ff38a75288a9da"
506
485
  dependencies = [
507
486
  "proc-macro2",
508
487
  "pyo3-macros-backend",
@@ -512,9 +491,9 @@ dependencies = [
512
491
 
513
492
  [[package]]
514
493
  name = "pyo3-macros-backend"
515
- version = "0.22.6"
494
+ version = "0.23.5"
516
495
  source = "registry+https://github.com/rust-lang/crates.io-index"
517
- checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe"
496
+ checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028"
518
497
  dependencies = [
519
498
  "heck",
520
499
  "proc-macro2",
@@ -525,9 +504,9 @@ dependencies = [
525
504
 
526
505
  [[package]]
527
506
  name = "quick-xml"
528
- version = "0.36.2"
507
+ version = "0.37.5"
529
508
  source = "registry+https://github.com/rust-lang/crates.io-index"
530
- checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe"
509
+ checksum = "331e97a1af0bf59823e6eadffe373d7b27f485be8748f71471c662c1f269b7fb"
531
510
  dependencies = [
532
511
  "memchr",
533
512
  "serde",
@@ -3,7 +3,7 @@ resolver = "2"
3
3
  members = ["crates/polyxml-core", "crates/polyxml-python"]
4
4
 
5
5
  [workspace.package]
6
- version = "0.2.0"
6
+ version = "0.3.0"
7
7
  edition = "2021"
8
8
  rust-version = "1.80"
9
9
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyxml
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -11,14 +11,14 @@ keywords = ["xml", "deserializer", "serializer", "data-binding", "quick-xml"]
11
11
  categories = ["parsing", "encoding"]
12
12
 
13
13
  [dependencies]
14
- quick-xml = { version = "0.36", features = ["serialize"] }
14
+ quick-xml = { version = "0.37", features = ["serialize"] }
15
15
  lexical-core = "1.0"
16
16
  memchr = "2.8"
17
17
  thiserror = "2.0"
18
18
  smallvec = "1.16"
19
19
 
20
20
  [dev-dependencies]
21
- criterion = { version = "0.5", default-features = false, features = ["cargo_bench_support"] }
21
+ criterion = { version = "0.7", default-features = false, features = ["cargo_bench_support"] }
22
22
  pretty_assertions = "1.4"
23
23
 
24
24
  [[bench]]
@@ -1,4 +1,6 @@
1
- use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
1
+ use std::hint::black_box;
2
+
3
+ use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
2
4
  use polyxml::schema::{FieldKind, FieldSchema, ModelSchema, ScalarType, ValueType};
3
5
  use polyxml::{deserialize, serialize};
4
6
  use std::sync::Arc;
@@ -14,7 +14,6 @@ crate-type = ["cdylib"]
14
14
 
15
15
  [dependencies]
16
16
  polyxml = { path = "../polyxml-core" }
17
- pyo3 = { version = "0.22", features = ["abi3-py312", "extension-module"] }
18
- quick-xml = { version = "0.36" }
17
+ pyo3 = { version = "0.23", features = ["abi3-py312", "extension-module"] }
19
18
  lexical-core = "1.0"
20
19
  smallvec = "1.16"
@@ -4,6 +4,7 @@
4
4
 
5
5
  use pyo3::prelude::*;
6
6
  use pyo3::types::{PyBytes, PyDict, PyList, PyString, PyTuple, PyType};
7
+ use pyo3::IntoPyObjectExt;
7
8
  use std::collections::HashMap;
8
9
  use std::sync::{Arc, RwLock};
9
10
 
@@ -69,7 +70,7 @@ fn unwrap_optional_type<'py>(type_obj: &Bound<'py, PyAny>) -> Bound<'py, PyAny>
69
70
 
70
71
  fn is_enum_class<'py>(py: Python<'py>, cls: &Bound<'py, PyAny>) -> bool {
71
72
  if let Ok(py_type) = cls.downcast::<PyType>() {
72
- if let Ok(enum_module) = py.import_bound("enum") {
73
+ if let Ok(enum_module) = py.import("enum") {
73
74
  if let Ok(enum_cls) = enum_module.getattr("Enum") {
74
75
  if let Ok(py_enum) = enum_cls.downcast::<PyType>() {
75
76
  return py_type.is_subclass(py_enum).unwrap_or(false);
@@ -160,7 +161,7 @@ fn extract_schema_from_class<'py>(
160
161
  let mut cached_fields = Vec::new();
161
162
 
162
163
  let type_hints: Option<Bound<'py, PyDict>> = py
163
- .import_bound("typing")
164
+ .import("typing")
164
165
  .ok()
165
166
  .and_then(|m| m.getattr("get_type_hints").ok())
166
167
  .and_then(|f| f.call1((cls,)).ok())
@@ -170,7 +171,7 @@ fn extract_schema_from_class<'py>(
170
171
  let model_fields: Bound<'py, PyDict> = cls.getattr("model_fields")?.downcast_into()?;
171
172
  for (name_obj, field_obj) in model_fields.iter() {
172
173
  let py_name: String = name_obj.extract()?;
173
- let py_string = PyString::new_bound(py, &py_name).unbind();
174
+ let py_string = PyString::new(py, &py_name).unbind();
174
175
  let mut xml_name = py_name.clone();
175
176
  let mut kind = FieldKind::Element;
176
177
 
@@ -223,7 +224,7 @@ fn extract_schema_from_class<'py>(
223
224
  let fields: Bound<'py, PyDict> = cls.getattr("__dataclass_fields__")?.downcast_into()?;
224
225
  for (name_obj, field_obj) in fields.iter() {
225
226
  let py_name: String = name_obj.extract()?;
226
- let py_string = PyString::new_bound(py, &py_name).unbind();
227
+ let py_string = PyString::new(py, &py_name).unbind();
227
228
  let mut xml_name = py_name.clone();
228
229
  let mut kind = FieldKind::Element;
229
230
 
@@ -333,7 +334,7 @@ fn convert_scalar_to_py<'py>(
333
334
  ) -> PyResult<PyObject> {
334
335
  match val {
335
336
  PolyValue::Null => Ok(py.None()),
336
- PolyValue::Bool(b) => Ok(b.to_object(py)),
337
+ PolyValue::Bool(b) => b.into_py_any(py),
337
338
  PolyValue::Int(i) => {
338
339
  if let Some(target_type) = py_type_opt {
339
340
  if is_enum_class(py, target_type) {
@@ -342,9 +343,9 @@ fn convert_scalar_to_py<'py>(
342
343
  }
343
344
  }
344
345
  }
345
- Ok(i.to_object(py))
346
+ i.into_py_any(py)
346
347
  }
347
- PolyValue::Float(f) => Ok(f.to_object(py)),
348
+ PolyValue::Float(f) => f.into_py_any(py),
348
349
  PolyValue::String(s) => {
349
350
  if let Some(target_type) = py_type_opt {
350
351
  if is_enum_class(py, target_type) {
@@ -368,52 +369,32 @@ fn convert_scalar_to_py<'py>(
368
369
 
369
370
  match type_name.as_str() {
370
371
  "Decimal" => {
371
- let decimal_cls = py.import_bound("decimal")?.getattr("Decimal")?;
372
+ let decimal_cls = py.import("decimal")?.getattr("Decimal")?;
372
373
  let dec = decimal_cls.call1((s.as_str(),))?;
373
374
  return Ok(dec.unbind());
374
375
  }
375
- "XmlDate" => {
376
- if let Ok(datatype_mod) = py.import_bound("pyxsdata.models.datatype") {
377
- if let Ok(cls) = datatype_mod.getattr("XmlDate") {
378
- if let Ok(val) = cls.call_method1("from_string", (s.as_str(),)) {
379
- return Ok(val.unbind());
380
- }
381
- }
376
+ "XmlDate" | "XmlDateTime" | "XmlTime" => {
377
+ if let Ok(val) = target_type.call_method1("from_string", (s.as_str(),)) {
378
+ return Ok(val.unbind());
382
379
  }
383
- if let Ok(datetime_mod) = py.import_bound("datetime") {
384
- if let Ok(cls) = datetime_mod.getattr("date") {
385
- if let Ok(val) = cls.call_method1("fromisoformat", (s.as_str(),)) {
386
- return Ok(val.unbind());
387
- }
388
- }
389
- }
390
- }
391
- "XmlDateTime" => {
392
- if let Ok(datatype_mod) = py.import_bound("pyxsdata.models.datatype") {
393
- if let Ok(cls) = datatype_mod.getattr("XmlDateTime") {
380
+ if let Ok(datatype_mod) = py.import("pyxsdata.models.datatype") {
381
+ if let Ok(cls) = datatype_mod.getattr(type_name.as_str()) {
394
382
  if let Ok(val) = cls.call_method1("from_string", (s.as_str(),)) {
395
383
  return Ok(val.unbind());
396
384
  }
397
385
  }
398
386
  }
399
- if let Ok(datetime_mod) = py.import_bound("datetime") {
400
- if let Ok(cls) = datetime_mod.getattr("datetime") {
401
- if let Ok(val) = cls.call_method1("fromisoformat", (s.as_str(),)) {
402
- return Ok(val.unbind());
403
- }
404
- }
405
- }
406
- }
407
- "XmlTime" => {
408
- if let Ok(datatype_mod) = py.import_bound("pyxsdata.models.datatype") {
409
- if let Ok(cls) = datatype_mod.getattr("XmlTime") {
410
- if let Ok(val) = cls.call_method1("from_string", (s.as_str(),)) {
411
- return Ok(val.unbind());
412
- }
413
- }
387
+ if let Ok(val) = target_type.call1((s.as_str(),)) {
388
+ return Ok(val.unbind());
414
389
  }
415
- if let Ok(datetime_mod) = py.import_bound("datetime") {
416
- if let Ok(cls) = datetime_mod.getattr("time") {
390
+ let mod_name = match type_name.as_str() {
391
+ "XmlDate" => "date",
392
+ "XmlDateTime" => "datetime",
393
+ "XmlTime" => "time",
394
+ _ => "",
395
+ };
396
+ if let Ok(datetime_mod) = py.import("datetime") {
397
+ if let Ok(cls) = datetime_mod.getattr(mod_name) {
417
398
  if let Ok(val) = cls.call_method1("fromisoformat", (s.as_str(),)) {
418
399
  return Ok(val.unbind());
419
400
  }
@@ -421,7 +402,10 @@ fn convert_scalar_to_py<'py>(
421
402
  }
422
403
  }
423
404
  "XmlDuration" => {
424
- if let Ok(datatype_mod) = py.import_bound("pyxsdata.models.datatype") {
405
+ if let Ok(val) = target_type.call1((s.as_str(),)) {
406
+ return Ok(val.unbind());
407
+ }
408
+ if let Ok(datatype_mod) = py.import("pyxsdata.models.datatype") {
425
409
  if let Ok(cls) = datatype_mod.getattr("XmlDuration") {
426
410
  if let Ok(val) = cls.call1((s.as_str(),)) {
427
411
  return Ok(val.unbind());
@@ -432,7 +416,7 @@ fn convert_scalar_to_py<'py>(
432
416
  _ => {}
433
417
  }
434
418
  }
435
- Ok(PyString::new_bound(py, s).into_any().unbind())
419
+ Ok(PyString::new(py, s).into_any().unbind())
436
420
  }
437
421
  _ => Ok(py.None()),
438
422
  }
@@ -447,7 +431,7 @@ fn poly_value_to_py<'py>(
447
431
  ) -> PyResult<PyObject> {
448
432
  match val {
449
433
  PolyValue::Null => Ok(py.None()),
450
- PolyValue::Bool(b) => Ok(b.to_object(py)),
434
+ PolyValue::Bool(b) => b.into_py_any(py),
451
435
  PolyValue::Int(_) | PolyValue::Float(_) | PolyValue::String(_) => {
452
436
  let st = match val_type {
453
437
  ValueType::Scalar(ref s) => s,
@@ -473,10 +457,10 @@ fn poly_value_to_py<'py>(
473
457
  poly_value_to_py(py, item, inner_type, inner_cls.as_ref(), field_meta)?;
474
458
  py_items.push(py_item);
475
459
  }
476
- let py_list = PyList::new_bound(py, &py_items);
460
+ let py_list = PyList::new(py, &py_items)?;
477
461
  Ok(py_list.into_any().unbind())
478
462
  } else {
479
- let py_list = PyList::empty_bound(py);
463
+ let py_list = PyList::empty(py);
480
464
  Ok(py_list.into_any().unbind())
481
465
  }
482
466
  }
@@ -525,7 +509,7 @@ fn poly_value_to_py<'py>(
525
509
  }
526
510
  }
527
511
  if all_found {
528
- let tuple = pyo3::types::PyTuple::new_bound(py, &args_vec);
512
+ let tuple = pyo3::types::PyTuple::new(py, &args_vec)?;
529
513
  if let Ok(instance) = target_cls.call1(tuple) {
530
514
  return Ok(instance.unbind());
531
515
  }
@@ -534,7 +518,7 @@ fn poly_value_to_py<'py>(
534
518
  }
535
519
 
536
520
  // Method 2: Keyword arguments with init=False post-init support
537
- let kwargs = PyDict::new_bound(py);
521
+ let kwargs = PyDict::new(py);
538
522
  let mut post_init_fields: Vec<(Py<PyString>, PyObject)> = Vec::new();
539
523
 
540
524
  for (i, field) in schema.fields.iter().enumerate() {
@@ -563,7 +547,7 @@ fn poly_value_to_py<'py>(
563
547
  kwargs.set_item(&field.name, py_val)?;
564
548
  } else {
565
549
  post_init_fields
566
- .push((PyString::new_bound(py, &field.name).unbind(), py_val));
550
+ .push((PyString::new(py, &field.name).unbind(), py_val));
567
551
  }
568
552
  }
569
553
  }
@@ -573,7 +557,7 @@ fn poly_value_to_py<'py>(
573
557
  }
574
558
  return Ok(instance.unbind());
575
559
  }
576
- let dict = PyDict::new_bound(py);
560
+ let dict = PyDict::new(py);
577
561
  for (k, v) in map {
578
562
  let py_v =
579
563
  poly_value_to_py(py, v, &ValueType::Scalar(ScalarType::Any), None, None)?;
@@ -582,7 +566,7 @@ fn poly_value_to_py<'py>(
582
566
  let instance = target_cls.call((), Some(&dict))?;
583
567
  Ok(instance.unbind())
584
568
  } else {
585
- let dict = PyDict::new_bound(py);
569
+ let dict = PyDict::new(py);
586
570
  for (k, v) in map {
587
571
  let py_v =
588
572
  poly_value_to_py(py, v, &ValueType::Scalar(ScalarType::Any), None, None)?;
@@ -780,7 +764,7 @@ fn serialize<'py>(
780
764
  let bytes = polyxml::serialize(root_name, &poly_val, &meta.schema, indent)
781
765
  .map_err(|e| pyo3::exceptions::PyValueError::new_err(e.to_string()))?;
782
766
 
783
- Ok(PyBytes::new_bound(py, &bytes))
767
+ Ok(PyBytes::new(py, &bytes))
784
768
  }
785
769
 
786
770
  #[pyfunction]
@@ -6,7 +6,66 @@ from enum import Enum
6
6
 
7
7
  import pytest
8
8
  from pydantic import BaseModel, Field
9
- from pyxsdata.models.datatype import XmlDate, XmlDateTime, XmlDuration, XmlTime
9
+
10
+ try:
11
+ from pyxsdata.models.datatype import XmlDate, XmlDateTime, XmlDuration, XmlTime
12
+ except ImportError:
13
+
14
+ class XmlDate:
15
+
16
+ def __init__(self, val: str):
17
+ self.val = val
18
+
19
+ @classmethod
20
+ def from_string(cls, val: str):
21
+ return cls(val)
22
+
23
+ def __eq__(self, other):
24
+ return isinstance(other, XmlDate) and self.val == other.val
25
+
26
+ def __str__(self):
27
+ return self.val
28
+
29
+ class XmlDateTime:
30
+
31
+ def __init__(self, val: str):
32
+ self.val = val
33
+
34
+ @classmethod
35
+ def from_string(cls, val: str):
36
+ return cls(val)
37
+
38
+ def __eq__(self, other):
39
+ return isinstance(other, XmlDateTime) and self.val == other.val
40
+
41
+ def __str__(self):
42
+ return self.val
43
+
44
+ class XmlTime:
45
+
46
+ def __init__(self, val: str):
47
+ self.val = val
48
+
49
+ @classmethod
50
+ def from_string(cls, val: str):
51
+ return cls(val)
52
+
53
+ def __eq__(self, other):
54
+ return isinstance(other, XmlTime) and self.val == other.val
55
+
56
+ def __str__(self):
57
+ return self.val
58
+
59
+ class XmlDuration:
60
+
61
+ def __init__(self, val: str):
62
+ self.val = val
63
+
64
+ def __eq__(self, other):
65
+ return isinstance(other, XmlDuration) and self.val == other.val
66
+
67
+ def __str__(self):
68
+ return self.val
10
69
 
11
70
  import polyxml
12
71
 
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "polyxml"
7
- version = "0.2.0"
7
+ version = "0.3.0"
8
8
  description = "High-performance, polyglot XML data-binding engine built in Rust"
9
9
  authors = [
10
10
  { name = "Bailey Nguyen", email = "bailey.tan.nguyen@gmail.com" }
File without changes
File without changes