str-to-obj 2023.9__tar.gz → 2023.10__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. {str-to-obj-2023.9 → str-to-obj-2023.10}/PKG-INFO +1 -1
  2. str-to-obj-2023.10/str_to_obj/task/comparison.py +64 -0
  3. {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/type/annotation.py +0 -4
  4. {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/version.py +3 -1
  5. {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj.egg-info/PKG-INFO +1 -1
  6. {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj.egg-info/SOURCES.txt +1 -0
  7. {str-to-obj-2023.9 → str-to-obj-2023.10}/MANIFEST.in +0 -0
  8. {str-to-obj-2023.9 → str-to-obj-2023.10}/README-COPYRIGHT-utf8.txt +0 -0
  9. {str-to-obj-2023.9 → str-to-obj-2023.10}/README-LICENCE-utf8.txt +0 -0
  10. {str-to-obj-2023.9 → str-to-obj-2023.10}/README.rst +0 -0
  11. {str-to-obj-2023.9 → str-to-obj-2023.10}/documentation/wiki/description.asciidoc +0 -0
  12. {str-to-obj-2023.9 → str-to-obj-2023.10}/pyproject.toml +0 -0
  13. {str-to-obj-2023.9 → str-to-obj-2023.10}/setup.cfg +0 -0
  14. {str-to-obj-2023.9 → str-to-obj-2023.10}/setup.py +0 -0
  15. {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/__init__.py +0 -0
  16. {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/interface/console.py +0 -0
  17. {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/main.py +0 -0
  18. {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/task/casting.py +0 -0
  19. {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/task/inspection.py +0 -0
  20. {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/type/hint.py +0 -0
  21. {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/type/hint_tree.py +0 -0
  22. {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj.egg-info/dependency_links.txt +0 -0
  23. {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj.egg-info/requires.txt +0 -0
  24. {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: str-to-obj
3
- Version: 2023.9
3
+ Version: 2023.10
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
@@ -0,0 +1,64 @@
1
+ # Copyright CNRS/Inria/UNS
2
+ # Contributor(s): Eric Debreuve (since 2023)
3
+ #
4
+ # eric.debreuve@cnrs.fr
5
+ #
6
+ # This software is governed by the CeCILL license under French law and
7
+ # abiding by the rules of distribution of free software. You can use,
8
+ # modify and/ or redistribute the software under the terms of the CeCILL
9
+ # license as circulated by CEA, CNRS and INRIA at the following URL
10
+ # "http://www.cecill.info".
11
+ #
12
+ # As a counterpart to the access to the source code and rights to copy,
13
+ # modify and redistribute granted by the license, users are provided only
14
+ # with a limited warranty and the software's author, the holder of the
15
+ # economic rights, and the successive licensors have only limited
16
+ # liability.
17
+ #
18
+ # In this respect, the user's attention is drawn to the risks associated
19
+ # with loading, using, modifying and/or developing or reproducing the
20
+ # software by the user in light of its specific status of free software,
21
+ # that may mean that it is complicated to manipulate, and that also
22
+ # therefore means that it is reserved for developers and experienced
23
+ # professionals having in-depth computer knowledge. Users are therefore
24
+ # encouraged to load and test the software's suitability as regards their
25
+ # requirements in conditions enabling the security of their systems and/or
26
+ # data to be ensured and, more generally, to use and operate it in the
27
+ # same conditions as regards security.
28
+ #
29
+ # The fact that you are presently reading this means that you have had
30
+ # knowledge of the CeCILL license and that you accept its terms.
31
+
32
+ from types import UnionType
33
+
34
+ from str_to_obj.type.hint_tree import hint_tree_t
35
+
36
+
37
+ def TypesAreCompatible(
38
+ one: hint_tree_t,
39
+ another: hint_tree_t,
40
+ /,
41
+ *,
42
+ strict_mode: bool = True,
43
+ second_should_be_wider: bool = False,
44
+ ) -> bool:
45
+ """"""
46
+ if one.type is UnionType:
47
+ return any(
48
+ TypesAreCompatible(_elm, another, strict_mode=strict_mode)
49
+ for _elm in one.elements
50
+ )
51
+ if another.type is UnionType:
52
+ return any(
53
+ TypesAreCompatible(one, _elm, strict_mode=strict_mode)
54
+ for _elm in another.elements
55
+ )
56
+
57
+ # TODO: Below code is certainly not general enough.
58
+ if strict_mode:
59
+ return issubclass(one.type, another.type) and issubclass(another.type, one.type)
60
+
61
+ if second_should_be_wider:
62
+ return issubclass(one.type, another.type)
63
+
64
+ return issubclass(one.type, another.type) or issubclass(another.type, one.type)
@@ -57,10 +57,6 @@ class annotation_t:
57
57
  """
58
58
  raise NotImplementedError
59
59
 
60
- def Issues(self) -> list[str]:
61
- """"""
62
- return []
63
-
64
60
  def ValueIsCompliant(self, value: Any, /) -> list[str]:
65
61
  """"""
66
62
  types = self.__class__.ACCEPTED_TYPES
@@ -29,4 +29,6 @@
29
29
  # The fact that you are presently reading this means that you have had
30
30
  # knowledge of the CeCILL license and that you accept its terms.
31
31
 
32
- __version__ = "2023.9"
32
+ __version__ = "2023.10"
33
+
34
+ # TODO: Switch to issue-manager.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: str-to-obj
3
- Version: 2023.9
3
+ Version: 2023.10
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
@@ -15,6 +15,7 @@ str_to_obj.egg-info/requires.txt
15
15
  str_to_obj.egg-info/top_level.txt
16
16
  str_to_obj/interface/console.py
17
17
  str_to_obj/task/casting.py
18
+ str_to_obj/task/comparison.py
18
19
  str_to_obj/task/inspection.py
19
20
  str_to_obj/type/annotation.py
20
21
  str_to_obj/type/hint.py
File without changes
File without changes
File without changes
File without changes
File without changes