str-to-obj 2025.1__tar.gz → 2025.3__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. {str_to_obj-2025.1 → str_to_obj-2025.3}/PKG-INFO +1 -1
  2. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/main.py +16 -20
  3. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/type/hint_tree.py +4 -3
  4. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/version.py +1 -1
  5. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj.egg-info/PKG-INFO +1 -1
  6. {str_to_obj-2025.1 → str_to_obj-2025.3}/MANIFEST.in +0 -0
  7. {str_to_obj-2025.1 → str_to_obj-2025.3}/README-COPYRIGHT-utf8.txt +0 -0
  8. {str_to_obj-2025.1 → str_to_obj-2025.3}/README-LICENCE-utf8.txt +0 -0
  9. {str_to_obj-2025.1 → str_to_obj-2025.3}/README.rst +0 -0
  10. {str_to_obj-2025.1 → str_to_obj-2025.3}/documentation/wiki/description.asciidoc +0 -0
  11. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/__init__.py +0 -0
  12. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/api/catalog.py +0 -0
  13. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/api/type.py +0 -0
  14. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/catalog/boolean.py +0 -0
  15. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/catalog/callable.py +0 -0
  16. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/catalog/choices.py +0 -0
  17. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/catalog/collection.py +0 -0
  18. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/catalog/number.py +0 -0
  19. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/catalog/path.py +0 -0
  20. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/interface/console.py +0 -0
  21. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/runtime/type.py +0 -0
  22. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/runtime/value.py +0 -0
  23. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/task/casting.py +0 -0
  24. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/task/comparison.py +0 -0
  25. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/task/inspection.py +0 -0
  26. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/type/annotation.py +0 -0
  27. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/type/hint.py +0 -0
  28. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/type/type.py +0 -0
  29. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj/type/value.py +0 -0
  30. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj.egg-info/SOURCES.txt +0 -0
  31. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj.egg-info/dependency_links.txt +0 -0
  32. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj.egg-info/requires.txt +0 -0
  33. {str_to_obj-2025.1 → str_to_obj-2025.3}/package/str_to_obj.egg-info/top_level.txt +0 -0
  34. {str_to_obj-2025.1 → str_to_obj-2025.3}/pyproject.toml +0 -0
  35. {str_to_obj-2025.1 → str_to_obj-2025.3}/requirements.txt +0 -0
  36. {str_to_obj-2025.1 → str_to_obj-2025.3}/setup.cfg +0 -0
  37. {str_to_obj-2025.1 → str_to_obj-2025.3}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: str-to-obj
3
- Version: 2025.1
3
+ Version: 2025.3
4
4
  Summary: Convert strings to Python objects guided by (potentially annotated) type hints
5
5
  Home-page: https://src.koda.cnrs.fr/eric.debreuve/str-to-obj/
6
6
  Author: Eric Debreuve
@@ -29,11 +29,7 @@ def ObjectFromStr(
29
29
  issues = [f'{string}: Invalid value; Expected="NONE" or "None" or "none".']
30
30
  return None, issues
31
31
 
32
- # value = _ObjectFromStr(string)
33
- try:
34
- value = bstr.literal_eval(string)
35
- except (SyntaxError, ValueError):
36
- value = string
32
+ value = _ObjectFromStr(string)
37
33
 
38
34
  if expected_type is None:
39
35
  return value, []
@@ -41,21 +37,21 @@ def ObjectFromStr(
41
37
  return CastValue(value, expected_type)
42
38
 
43
39
 
44
- # def _ObjectFromStr(string: str | h.Any, /)-> h.Any:
45
- # """"""
46
- # # if not isinstance(string, str):
47
- # # return string
48
- #
49
- # try:
50
- # value = bstr.literal_eval(string)
51
- # except (SyntaxError, ValueError):
52
- # value = string
53
- #
54
- # # if isinstance(value, h.Sequence) and not isinstance(value, str):
55
- # # stripe = type(value)
56
- # # value = stripe(_ObjectFromStr(_elm) for _elm in value)
57
- #
58
- # return value
40
+ def _ObjectFromStr(string: str | h.Any, /)-> h.Any:
41
+ """"""
42
+ if not isinstance(string, str):
43
+ return string
44
+
45
+ try:
46
+ value = bstr.literal_eval(string)
47
+ except (SyntaxError, ValueError):
48
+ value = string
49
+
50
+ if isinstance(value, h.Sequence) and not isinstance(value, str):
51
+ stripe = type(value)
52
+ value = stripe(_ObjectFromStr(_elm) for _elm in value)
53
+
54
+ return value
59
55
 
60
56
 
61
57
  """
@@ -17,9 +17,10 @@ from str_to_obj.type.hint import (
17
17
  any_hint_h,
18
18
  complex_hint_additions_h,
19
19
  non_complex_hint_h,
20
- simple_hint_h,
21
20
  )
22
21
 
22
+ hint_node_type_h = non_complex_hint_h | t.UnionType | t.EllipsisType | type[t.NoneType]
23
+
23
24
 
24
25
  @d.dataclass(slots=True, repr=False, eq=False)
25
26
  class _hint_node_t:
@@ -29,7 +30,7 @@ class _hint_node_t:
29
30
  otherwise.
30
31
  """
31
32
 
32
- type: non_complex_hint_h | t.UnionType | t.EllipsisType | type[t.NoneType]
33
+ type: hint_node_type_h
33
34
  annotations: tuple[annotation_t, ...] = d.field(default_factory=tuple)
34
35
  literal_s: tuple[h.Any, ...] | None = None
35
36
 
@@ -112,7 +113,7 @@ class hint_t(_hint_node_t):
112
113
  return output
113
114
 
114
115
  @property
115
- def template(self) -> simple_hint_h | dict[int, h.Any] | None:
116
+ def template(self) -> type[hint_node_type_h] | dict[int, h.Any] | None:
116
117
  """"""
117
118
  if self.type is t.NoneType:
118
119
  return None
@@ -4,7 +4,7 @@ Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
4
4
  SEE COPYRIGHT NOTICE BELOW
5
5
  """
6
6
 
7
- __version__ = "2025.1"
7
+ __version__ = "2025.3"
8
8
 
9
9
 
10
10
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: str-to-obj
3
- Version: 2025.1
3
+ Version: 2025.3
4
4
  Summary: Convert strings to Python objects guided by (potentially annotated) type hints
5
5
  Home-page: https://src.koda.cnrs.fr/eric.debreuve/str-to-obj/
6
6
  Author: Eric Debreuve
File without changes
File without changes
File without changes
File without changes
File without changes