str-to-obj 2023.11__py3-none-any.whl → 2025.1__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- str_to_obj/__init__.py +64 -32
- str_to_obj/api/catalog.py +58 -0
- str_to_obj/api/type.py +58 -0
- str_to_obj/catalog/boolean.py +99 -0
- str_to_obj/catalog/callable.py +99 -0
- str_to_obj/catalog/choices.py +101 -0
- str_to_obj/catalog/collection.py +175 -0
- str_to_obj/catalog/number.py +142 -0
- str_to_obj/catalog/path.py +117 -0
- str_to_obj/interface/console.py +59 -37
- str_to_obj/main.py +76 -36
- str_to_obj/runtime/type.py +58 -0
- str_to_obj/runtime/value.py +56 -0
- str_to_obj/task/casting.py +88 -59
- str_to_obj/task/comparison.py +58 -36
- str_to_obj/task/inspection.py +59 -35
- str_to_obj/type/annotation.py +61 -43
- str_to_obj/type/hint.py +59 -38
- str_to_obj/type/hint_tree.py +122 -63
- str_to_obj/type/type.py +121 -0
- str_to_obj/type/value.py +69 -0
- str_to_obj/version.py +54 -34
- {str_to_obj-2023.11.dist-info → str_to_obj-2025.1.dist-info}/METADATA +90 -48
- str_to_obj-2025.1.dist-info/RECORD +26 -0
- {str_to_obj-2023.11.dist-info → str_to_obj-2025.1.dist-info}/WHEEL +1 -1
- str_to_obj-2023.11.dist-info/RECORD +0 -14
- {str_to_obj-2023.11.dist-info → str_to_obj-2025.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
"""
|
2
|
+
Copyright CNRS/Inria/UniCA
|
3
|
+
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
|
+
SEE COPYRIGHT NOTICE BELOW
|
5
|
+
"""
|
6
|
+
|
7
|
+
import typing as h
|
8
|
+
|
9
|
+
from str_to_obj.type.type import any_type_t
|
10
|
+
|
11
|
+
ANY_TYPE = any_type_t.NewForHint(h.Any)
|
12
|
+
|
13
|
+
|
14
|
+
"""
|
15
|
+
COPYRIGHT NOTICE
|
16
|
+
|
17
|
+
This software is governed by the CeCILL license under French law and
|
18
|
+
abiding by the rules of distribution of free software. You can use,
|
19
|
+
modify and/ or redistribute the software under the terms of the CeCILL
|
20
|
+
license as circulated by CEA, CNRS and INRIA at the following URL
|
21
|
+
"http://www.cecill.info".
|
22
|
+
|
23
|
+
As a counterpart to the access to the source code and rights to copy,
|
24
|
+
modify and redistribute granted by the license, users are provided only
|
25
|
+
with a limited warranty and the software's author, the holder of the
|
26
|
+
economic rights, and the successive licensors have only limited
|
27
|
+
liability.
|
28
|
+
|
29
|
+
In this respect, the user's attention is drawn to the risks associated
|
30
|
+
with loading, using, modifying and/or developing or reproducing the
|
31
|
+
software by the user in light of its specific status of free software,
|
32
|
+
that may mean that it is complicated to manipulate, and that also
|
33
|
+
therefore means that it is reserved for developers and experienced
|
34
|
+
professionals having in-depth computer knowledge. Users are therefore
|
35
|
+
encouraged to load and test the software's suitability as regards their
|
36
|
+
requirements in conditions enabling the security of their systems and/or
|
37
|
+
data to be ensured and, more generally, to use and operate it in the
|
38
|
+
same conditions as regards security.
|
39
|
+
|
40
|
+
The fact that you are presently reading this means that you have had
|
41
|
+
knowledge of the CeCILL license and that you accept its terms.
|
42
|
+
|
43
|
+
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
44
|
+
|
45
|
+
This software is being developed by Eric Debreuve, a CNRS employee and
|
46
|
+
member of team Morpheme.
|
47
|
+
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
48
|
+
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
49
|
+
I3S, and Laboratory iBV.
|
50
|
+
|
51
|
+
CNRS: https://www.cnrs.fr/index.php/en
|
52
|
+
Inria: https://www.inria.fr/en/
|
53
|
+
UniCA: https://univ-cotedazur.eu/
|
54
|
+
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
55
|
+
I3S: https://www.i3s.unice.fr/en/
|
56
|
+
iBV: http://ibv.unice.fr/
|
57
|
+
Team Morpheme: https://team.inria.fr/morpheme/
|
58
|
+
"""
|
@@ -0,0 +1,56 @@
|
|
1
|
+
"""
|
2
|
+
Copyright CNRS/Inria/UniCA
|
3
|
+
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
|
+
SEE COPYRIGHT NOTICE BELOW
|
5
|
+
"""
|
6
|
+
|
7
|
+
from str_to_obj.type.value import invalid_value_t
|
8
|
+
|
9
|
+
INVALID_VALUE = invalid_value_t()
|
10
|
+
|
11
|
+
|
12
|
+
"""
|
13
|
+
COPYRIGHT NOTICE
|
14
|
+
|
15
|
+
This software is governed by the CeCILL license under French law and
|
16
|
+
abiding by the rules of distribution of free software. You can use,
|
17
|
+
modify and/ or redistribute the software under the terms of the CeCILL
|
18
|
+
license as circulated by CEA, CNRS and INRIA at the following URL
|
19
|
+
"http://www.cecill.info".
|
20
|
+
|
21
|
+
As a counterpart to the access to the source code and rights to copy,
|
22
|
+
modify and redistribute granted by the license, users are provided only
|
23
|
+
with a limited warranty and the software's author, the holder of the
|
24
|
+
economic rights, and the successive licensors have only limited
|
25
|
+
liability.
|
26
|
+
|
27
|
+
In this respect, the user's attention is drawn to the risks associated
|
28
|
+
with loading, using, modifying and/or developing or reproducing the
|
29
|
+
software by the user in light of its specific status of free software,
|
30
|
+
that may mean that it is complicated to manipulate, and that also
|
31
|
+
therefore means that it is reserved for developers and experienced
|
32
|
+
professionals having in-depth computer knowledge. Users are therefore
|
33
|
+
encouraged to load and test the software's suitability as regards their
|
34
|
+
requirements in conditions enabling the security of their systems and/or
|
35
|
+
data to be ensured and, more generally, to use and operate it in the
|
36
|
+
same conditions as regards security.
|
37
|
+
|
38
|
+
The fact that you are presently reading this means that you have had
|
39
|
+
knowledge of the CeCILL license and that you accept its terms.
|
40
|
+
|
41
|
+
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
42
|
+
|
43
|
+
This software is being developed by Eric Debreuve, a CNRS employee and
|
44
|
+
member of team Morpheme.
|
45
|
+
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
46
|
+
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
47
|
+
I3S, and Laboratory iBV.
|
48
|
+
|
49
|
+
CNRS: https://www.cnrs.fr/index.php/en
|
50
|
+
Inria: https://www.inria.fr/en/
|
51
|
+
UniCA: https://univ-cotedazur.eu/
|
52
|
+
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
53
|
+
I3S: https://www.i3s.unice.fr/en/
|
54
|
+
iBV: http://ibv.unice.fr/
|
55
|
+
Team Morpheme: https://team.inria.fr/morpheme/
|
56
|
+
"""
|
str_to_obj/task/casting.py
CHANGED
@@ -1,43 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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 __future__ import annotations
|
33
|
-
|
34
|
-
import dataclasses as dtcl
|
1
|
+
"""
|
2
|
+
Copyright CNRS/Inria/UniCA
|
3
|
+
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
|
+
SEE COPYRIGHT NOTICE BELOW
|
5
|
+
"""
|
6
|
+
|
7
|
+
import dataclasses as d
|
8
|
+
import types as t
|
9
|
+
import typing as h
|
35
10
|
from pathlib import Path as path_t
|
36
|
-
from types import EllipsisType, NoneType, UnionType
|
37
|
-
from typing import Any, Iterable
|
38
11
|
|
39
12
|
from str_to_obj.type.hint import any_hint_h, simple_hint_h
|
40
|
-
from str_to_obj.type.hint_tree import
|
13
|
+
from str_to_obj.type.hint_tree import hint_t
|
41
14
|
|
42
15
|
|
43
16
|
class _not_a_leaf_node_t:
|
@@ -47,7 +20,7 @@ class _not_a_leaf_node_t:
|
|
47
20
|
_NOT_A_LEAF_NODE = _not_a_leaf_node_t()
|
48
21
|
|
49
22
|
|
50
|
-
@
|
23
|
+
@d.dataclass(slots=True, repr=False, eq=False)
|
51
24
|
class _value_node_t:
|
52
25
|
"""
|
53
26
|
Leave elements to the tree.
|
@@ -55,23 +28,23 @@ class _value_node_t:
|
|
55
28
|
"""
|
56
29
|
|
57
30
|
type: simple_hint_h = None
|
58
|
-
leaf_value: Any | None = _NOT_A_LEAF_NODE
|
31
|
+
leaf_value: h.Any | None = _NOT_A_LEAF_NODE
|
59
32
|
|
60
33
|
|
61
|
-
@
|
34
|
+
@d.dataclass(slots=True, repr=False, eq=False)
|
62
35
|
class _value_tree_t(_value_node_t):
|
63
|
-
elements: tuple[
|
36
|
+
elements: tuple[h.Self, ...] = None
|
64
37
|
|
65
38
|
@classmethod
|
66
|
-
def NewFromValue(cls, value: Any, /) ->
|
39
|
+
def NewFromValue(cls, value: h.Any, /) -> h.Self:
|
67
40
|
""""""
|
68
|
-
if isinstance(value, Iterable) and not isinstance(value, str):
|
41
|
+
if isinstance(value, h.Iterable) and not isinstance(value, str):
|
69
42
|
elements = tuple(cls.NewFromValue(_elm) for _elm in value)
|
70
43
|
return cls(type=type(value), elements=elements)
|
71
44
|
|
72
45
|
return cls(leaf_value=value)
|
73
46
|
|
74
|
-
def _RebuiltValue(self) -> Any:
|
47
|
+
def _RebuiltValue(self) -> h.Any:
|
75
48
|
""""""
|
76
49
|
if self.leaf_value is _NOT_A_LEAF_NODE:
|
77
50
|
return self.type(_elm._RebuiltValue() for _elm in self.elements)
|
@@ -79,8 +52,8 @@ class _value_tree_t(_value_node_t):
|
|
79
52
|
return self.leaf_value
|
80
53
|
|
81
54
|
def CastValue(
|
82
|
-
self, hint_tree:
|
83
|
-
) -> tuple[Any, list[str]] | list[str]:
|
55
|
+
self, hint_tree: hint_t, /, *, only_check_validity: bool = False
|
56
|
+
) -> tuple[h.Any, list[str]] | list[str]:
|
84
57
|
""""""
|
85
58
|
issues = self._CastToHint(hint_tree)
|
86
59
|
if issues.__len__() > 0:
|
@@ -94,7 +67,7 @@ class _value_tree_t(_value_node_t):
|
|
94
67
|
else:
|
95
68
|
return self._RebuiltValue(), []
|
96
69
|
|
97
|
-
def _CastToHint(self, hint_node:
|
70
|
+
def _CastToHint(self, hint_node: hint_t, /) -> list[str]:
|
98
71
|
"""
|
99
72
|
Returned value=the value tree has been successfully cast to the hint tree
|
100
73
|
specification, or not.
|
@@ -102,10 +75,10 @@ class _value_tree_t(_value_node_t):
|
|
102
75
|
hn_type = hint_node.type
|
103
76
|
hn_elements = hint_node.elements
|
104
77
|
|
105
|
-
if hn_type is Any:
|
78
|
+
if hn_type is h.Any:
|
106
79
|
return self._CompliesWithAnnotations(hint_node)
|
107
80
|
|
108
|
-
if hn_type is NoneType:
|
81
|
+
if hn_type is t.NoneType:
|
109
82
|
# None is not supposed to have annotations. They are ignored if it does.
|
110
83
|
if self.leaf_value is None:
|
111
84
|
output = []
|
@@ -113,7 +86,7 @@ class _value_tree_t(_value_node_t):
|
|
113
86
|
output = [f"{self.leaf_value}: Invalid value; Expected=None."]
|
114
87
|
return output
|
115
88
|
|
116
|
-
if hn_type is UnionType:
|
89
|
+
if hn_type is t.UnionType:
|
117
90
|
issues = []
|
118
91
|
for element in hn_elements:
|
119
92
|
local_issues = self._CastToHint(element)
|
@@ -167,8 +140,11 @@ class _value_tree_t(_value_node_t):
|
|
167
140
|
rebuilt = self._RebuiltValue()
|
168
141
|
try:
|
169
142
|
_ = hn_type(rebuilt)
|
170
|
-
except:
|
171
|
-
return [
|
143
|
+
except Exception as exception:
|
144
|
+
return [
|
145
|
+
f"{rebuilt}: Cannot be cast to type {hn_type.__name__} "
|
146
|
+
f"({exception.__class__.__name__})."
|
147
|
+
]
|
172
148
|
else:
|
173
149
|
self.type = hn_type
|
174
150
|
|
@@ -176,7 +152,9 @@ class _value_tree_t(_value_node_t):
|
|
176
152
|
|
177
153
|
n_value_elements = self.elements.__len__()
|
178
154
|
n_hint_elements = hn_elements.__len__()
|
179
|
-
has_ellipsis = (n_hint_elements == 2) and (
|
155
|
+
has_ellipsis = (n_hint_elements == 2) and (
|
156
|
+
hn_elements[1].type is t.EllipsisType
|
157
|
+
)
|
180
158
|
should_fake_ellipsis = (n_hint_elements == 1) and issubclass(
|
181
159
|
hn_type, (list, set)
|
182
160
|
)
|
@@ -203,22 +181,73 @@ class _value_tree_t(_value_node_t):
|
|
203
181
|
f"Expected=Value following template {hint_node.template_as_str}."
|
204
182
|
]
|
205
183
|
|
206
|
-
def _CompliesWithAnnotations(self, hint_node:
|
184
|
+
def _CompliesWithAnnotations(self, hint_node: hint_t, /) -> list[str]:
|
207
185
|
""""""
|
208
186
|
output = []
|
209
187
|
|
210
188
|
for annotation in hint_node.annotations:
|
211
|
-
output.extend(annotation.
|
189
|
+
output.extend(annotation.ValueIssues(self._RebuiltValue()))
|
212
190
|
|
213
191
|
return output
|
214
192
|
|
215
193
|
|
216
194
|
def CastValue(
|
217
|
-
value: Any,
|
218
|
-
|
195
|
+
value: h.Any,
|
196
|
+
hint: any_hint_h | hint_t,
|
197
|
+
/,
|
198
|
+
*,
|
199
|
+
only_check_validity: bool = False,
|
200
|
+
) -> tuple[h.Any, list[str]] | list[str]:
|
219
201
|
""""""
|
220
202
|
value_tree = _value_tree_t.NewFromValue(value)
|
221
|
-
if not isinstance(hint,
|
222
|
-
hint =
|
203
|
+
if not isinstance(hint, hint_t):
|
204
|
+
hint = hint_t.NewForHint(hint)
|
223
205
|
|
224
206
|
return value_tree.CastValue(hint, only_check_validity=only_check_validity)
|
207
|
+
|
208
|
+
|
209
|
+
"""
|
210
|
+
COPYRIGHT NOTICE
|
211
|
+
|
212
|
+
This software is governed by the CeCILL license under French law and
|
213
|
+
abiding by the rules of distribution of free software. You can use,
|
214
|
+
modify and/ or redistribute the software under the terms of the CeCILL
|
215
|
+
license as circulated by CEA, CNRS and INRIA at the following URL
|
216
|
+
"http://www.cecill.info".
|
217
|
+
|
218
|
+
As a counterpart to the access to the source code and rights to copy,
|
219
|
+
modify and redistribute granted by the license, users are provided only
|
220
|
+
with a limited warranty and the software's author, the holder of the
|
221
|
+
economic rights, and the successive licensors have only limited
|
222
|
+
liability.
|
223
|
+
|
224
|
+
In this respect, the user's attention is drawn to the risks associated
|
225
|
+
with loading, using, modifying and/or developing or reproducing the
|
226
|
+
software by the user in light of its specific status of free software,
|
227
|
+
that may mean that it is complicated to manipulate, and that also
|
228
|
+
therefore means that it is reserved for developers and experienced
|
229
|
+
professionals having in-depth computer knowledge. Users are therefore
|
230
|
+
encouraged to load and test the software's suitability as regards their
|
231
|
+
requirements in conditions enabling the security of their systems and/or
|
232
|
+
data to be ensured and, more generally, to use and operate it in the
|
233
|
+
same conditions as regards security.
|
234
|
+
|
235
|
+
The fact that you are presently reading this means that you have had
|
236
|
+
knowledge of the CeCILL license and that you accept its terms.
|
237
|
+
|
238
|
+
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
239
|
+
|
240
|
+
This software is being developed by Eric Debreuve, a CNRS employee and
|
241
|
+
member of team Morpheme.
|
242
|
+
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
243
|
+
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
244
|
+
I3S, and Laboratory iBV.
|
245
|
+
|
246
|
+
CNRS: https://www.cnrs.fr/index.php/en
|
247
|
+
Inria: https://www.inria.fr/en/
|
248
|
+
UniCA: https://univ-cotedazur.eu/
|
249
|
+
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
250
|
+
I3S: https://www.i3s.unice.fr/en/
|
251
|
+
iBV: http://ibv.unice.fr/
|
252
|
+
Team Morpheme: https://team.inria.fr/morpheme/
|
253
|
+
"""
|
str_to_obj/task/comparison.py
CHANGED
@@ -1,43 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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.
|
1
|
+
"""
|
2
|
+
Copyright CNRS/Inria/UniCA
|
3
|
+
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
|
+
SEE COPYRIGHT NOTICE BELOW
|
5
|
+
"""
|
31
6
|
|
7
|
+
import types as t
|
32
8
|
import typing as h
|
33
|
-
from types import UnionType
|
34
9
|
|
35
|
-
from str_to_obj.type.hint_tree import
|
10
|
+
from str_to_obj.type.hint_tree import hint_t
|
36
11
|
|
37
12
|
|
38
13
|
def TypesAreCompatible(
|
39
|
-
one:
|
40
|
-
another:
|
14
|
+
one: hint_t,
|
15
|
+
another: hint_t,
|
41
16
|
/,
|
42
17
|
*,
|
43
18
|
strict_mode: bool = True,
|
@@ -47,12 +22,12 @@ def TypesAreCompatible(
|
|
47
22
|
if h.Any in (one.type, another.type):
|
48
23
|
return True
|
49
24
|
|
50
|
-
if one.type is UnionType:
|
25
|
+
if one.type is t.UnionType:
|
51
26
|
return any(
|
52
27
|
TypesAreCompatible(_elm, another, strict_mode=strict_mode)
|
53
28
|
for _elm in one.elements
|
54
29
|
)
|
55
|
-
if another.type is UnionType:
|
30
|
+
if another.type is t.UnionType:
|
56
31
|
return any(
|
57
32
|
TypesAreCompatible(one, _elm, strict_mode=strict_mode)
|
58
33
|
for _elm in another.elements
|
@@ -66,3 +41,50 @@ def TypesAreCompatible(
|
|
66
41
|
return issubclass(one.type, another.type)
|
67
42
|
|
68
43
|
return issubclass(one.type, another.type) or issubclass(another.type, one.type)
|
44
|
+
|
45
|
+
|
46
|
+
"""
|
47
|
+
COPYRIGHT NOTICE
|
48
|
+
|
49
|
+
This software is governed by the CeCILL license under French law and
|
50
|
+
abiding by the rules of distribution of free software. You can use,
|
51
|
+
modify and/ or redistribute the software under the terms of the CeCILL
|
52
|
+
license as circulated by CEA, CNRS and INRIA at the following URL
|
53
|
+
"http://www.cecill.info".
|
54
|
+
|
55
|
+
As a counterpart to the access to the source code and rights to copy,
|
56
|
+
modify and redistribute granted by the license, users are provided only
|
57
|
+
with a limited warranty and the software's author, the holder of the
|
58
|
+
economic rights, and the successive licensors have only limited
|
59
|
+
liability.
|
60
|
+
|
61
|
+
In this respect, the user's attention is drawn to the risks associated
|
62
|
+
with loading, using, modifying and/or developing or reproducing the
|
63
|
+
software by the user in light of its specific status of free software,
|
64
|
+
that may mean that it is complicated to manipulate, and that also
|
65
|
+
therefore means that it is reserved for developers and experienced
|
66
|
+
professionals having in-depth computer knowledge. Users are therefore
|
67
|
+
encouraged to load and test the software's suitability as regards their
|
68
|
+
requirements in conditions enabling the security of their systems and/or
|
69
|
+
data to be ensured and, more generally, to use and operate it in the
|
70
|
+
same conditions as regards security.
|
71
|
+
|
72
|
+
The fact that you are presently reading this means that you have had
|
73
|
+
knowledge of the CeCILL license and that you accept its terms.
|
74
|
+
|
75
|
+
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
76
|
+
|
77
|
+
This software is being developed by Eric Debreuve, a CNRS employee and
|
78
|
+
member of team Morpheme.
|
79
|
+
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
80
|
+
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
81
|
+
I3S, and Laboratory iBV.
|
82
|
+
|
83
|
+
CNRS: https://www.cnrs.fr/index.php/en
|
84
|
+
Inria: https://www.inria.fr/en/
|
85
|
+
UniCA: https://univ-cotedazur.eu/
|
86
|
+
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
87
|
+
I3S: https://www.i3s.unice.fr/en/
|
88
|
+
iBV: http://ibv.unice.fr/
|
89
|
+
Team Morpheme: https://team.inria.fr/morpheme/
|
90
|
+
"""
|
str_to_obj/task/inspection.py
CHANGED
@@ -1,35 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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 typing import Any
|
1
|
+
"""
|
2
|
+
Copyright CNRS/Inria/UniCA
|
3
|
+
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
|
+
SEE COPYRIGHT NOTICE BELOW
|
5
|
+
"""
|
6
|
+
|
7
|
+
import typing as h
|
33
8
|
|
34
9
|
from str_to_obj.type.annotation import annotation_t
|
35
10
|
from str_to_obj.type.hint import annotated_hint_t, any_hint_h, raw_hint_h
|
@@ -45,20 +20,69 @@ def TypeOfAnnotatedHint(annotated_hint: annotated_hint_t, /) -> raw_hint_h:
|
|
45
20
|
return annotated_hint.__args__[0]
|
46
21
|
|
47
22
|
|
48
|
-
def AnnotationsOfAnnotatedHint(
|
23
|
+
def AnnotationsOfAnnotatedHint(
|
24
|
+
annotated_hint: annotated_hint_t, /
|
25
|
+
) -> tuple[h.Any, ...]:
|
49
26
|
""""""
|
50
27
|
output = tuple(annotated_hint.__metadata__)
|
51
28
|
if all(isinstance(_elm, annotation_t) for _elm in output):
|
52
29
|
return output
|
53
30
|
|
54
31
|
raise ValueError(
|
55
|
-
f'
|
32
|
+
f'Not all elements of {output} are of type "{annotation_t.__name__}".'
|
56
33
|
)
|
57
34
|
|
58
35
|
|
59
|
-
def HintComponents(hint: any_hint_h, /) -> tuple[raw_hint_h, tuple[Any, ...]]:
|
36
|
+
def HintComponents(hint: any_hint_h, /) -> tuple[raw_hint_h, tuple[h.Any, ...]]:
|
60
37
|
""""""
|
61
38
|
if IsAnnotated(hint):
|
62
39
|
return TypeOfAnnotatedHint(hint), AnnotationsOfAnnotatedHint(hint)
|
63
40
|
|
64
41
|
return hint, ()
|
42
|
+
|
43
|
+
|
44
|
+
"""
|
45
|
+
COPYRIGHT NOTICE
|
46
|
+
|
47
|
+
This software is governed by the CeCILL license under French law and
|
48
|
+
abiding by the rules of distribution of free software. You can use,
|
49
|
+
modify and/ or redistribute the software under the terms of the CeCILL
|
50
|
+
license as circulated by CEA, CNRS and INRIA at the following URL
|
51
|
+
"http://www.cecill.info".
|
52
|
+
|
53
|
+
As a counterpart to the access to the source code and rights to copy,
|
54
|
+
modify and redistribute granted by the license, users are provided only
|
55
|
+
with a limited warranty and the software's author, the holder of the
|
56
|
+
economic rights, and the successive licensors have only limited
|
57
|
+
liability.
|
58
|
+
|
59
|
+
In this respect, the user's attention is drawn to the risks associated
|
60
|
+
with loading, using, modifying and/or developing or reproducing the
|
61
|
+
software by the user in light of its specific status of free software,
|
62
|
+
that may mean that it is complicated to manipulate, and that also
|
63
|
+
therefore means that it is reserved for developers and experienced
|
64
|
+
professionals having in-depth computer knowledge. Users are therefore
|
65
|
+
encouraged to load and test the software's suitability as regards their
|
66
|
+
requirements in conditions enabling the security of their systems and/or
|
67
|
+
data to be ensured and, more generally, to use and operate it in the
|
68
|
+
same conditions as regards security.
|
69
|
+
|
70
|
+
The fact that you are presently reading this means that you have had
|
71
|
+
knowledge of the CeCILL license and that you accept its terms.
|
72
|
+
|
73
|
+
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
74
|
+
|
75
|
+
This software is being developed by Eric Debreuve, a CNRS employee and
|
76
|
+
member of team Morpheme.
|
77
|
+
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
78
|
+
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
79
|
+
I3S, and Laboratory iBV.
|
80
|
+
|
81
|
+
CNRS: https://www.cnrs.fr/index.php/en
|
82
|
+
Inria: https://www.inria.fr/en/
|
83
|
+
UniCA: https://univ-cotedazur.eu/
|
84
|
+
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
85
|
+
I3S: https://www.i3s.unice.fr/en/
|
86
|
+
iBV: http://ibv.unice.fr/
|
87
|
+
Team Morpheme: https://team.inria.fr/morpheme/
|
88
|
+
"""
|