str-to-obj 2023.9__py3-none-any.whl → 2023.10__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
str_to_obj/version.py CHANGED
@@ -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
@@ -1,13 +1,14 @@
1
1
  str_to_obj/__init__.py,sha256=odgBU079fpQMu9GXhY0Lc19Rris-8Oa60Dd4F5SxGpQ,1735
2
2
  str_to_obj/main.py,sha256=YxjO1kyeZxGf_31KRZVZ39F7gr0gYM1OyOa7Y8m4iG8,2488
3
- str_to_obj/version.py,sha256=h_28GC82BUnGRBLW-WX1hQ4x2BvPR7PQc0CtGX1rEIQ,1575
3
+ str_to_obj/version.py,sha256=uPN8AFfSMa4EZJiULZi88nsmrgs1XMgDFs63OrNF60U,1610
4
4
  str_to_obj/interface/console.py,sha256=PHcDGFmscXYSrPOJRjmlBPglQUBBGUhe1Bov3pthGT0,2414
5
5
  str_to_obj/task/casting.py,sha256=74eIRKpokqq-JqEK0UwRSQs1F4Zdj8pRDQXAPkqg3Ug,8468
6
+ str_to_obj/task/comparison.py,sha256=TLw6uPzBSx9Z3EocQYlbWhSrscaxY0wfrKFv_jtPG7g,2486
6
7
  str_to_obj/task/inspection.py,sha256=dwaK4uMN5iPgcWWVnFu86eSkuPy1G_phBAGTqEa_414,2488
7
- str_to_obj/type/annotation.py,sha256=4j5ZfezmF4Ui43ohCL6MTll2vdXCe4UiJbKRQRDvxvk,3310
8
+ str_to_obj/type/annotation.py,sha256=bR7tQVfYmAohizn4APx_D0aNoPo6gMjyFRoa-QpDNKM,3241
8
9
  str_to_obj/type/hint.py,sha256=Jv3m1VbXICsUwPTCFidW6A1bX-xgNU2twRP_H1DX5v4,2221
9
10
  str_to_obj/type/hint_tree.py,sha256=0ELSPbnvaES_oI-Ze1nT195LO4HgkyZx1N38bOvrmCw,5715
10
- str_to_obj-2023.9.dist-info/METADATA,sha256=FDjtsv2-BjP6TQanP0fFLIbZuor44pX-V3TNgM-AD3Y,5389
11
- str_to_obj-2023.9.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
12
- str_to_obj-2023.9.dist-info/top_level.txt,sha256=h-6bR_TAnXRGVSLTeNPlivlaG64xYM3E__Xg7sCgeug,11
13
- str_to_obj-2023.9.dist-info/RECORD,,
11
+ str_to_obj-2023.10.dist-info/METADATA,sha256=hM73PdF8rFOQP24H6ceXQD_U6wBZ2dvFakph2B_zY9w,5390
12
+ str_to_obj-2023.10.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
13
+ str_to_obj-2023.10.dist-info/top_level.txt,sha256=h-6bR_TAnXRGVSLTeNPlivlaG64xYM3E__Xg7sCgeug,11
14
+ str_to_obj-2023.10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5