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.
- {str-to-obj-2023.9 → str-to-obj-2023.10}/PKG-INFO +1 -1
- str-to-obj-2023.10/str_to_obj/task/comparison.py +64 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/type/annotation.py +0 -4
- {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/version.py +3 -1
- {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj.egg-info/PKG-INFO +1 -1
- {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj.egg-info/SOURCES.txt +1 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/MANIFEST.in +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/README-COPYRIGHT-utf8.txt +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/README-LICENCE-utf8.txt +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/README.rst +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/documentation/wiki/description.asciidoc +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/pyproject.toml +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/setup.cfg +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/setup.py +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/__init__.py +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/interface/console.py +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/main.py +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/task/casting.py +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/task/inspection.py +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/type/hint.py +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj/type/hint_tree.py +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj.egg-info/dependency_links.txt +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj.egg-info/requires.txt +0 -0
- {str-to-obj-2023.9 → str-to-obj-2023.10}/str_to_obj.egg-info/top_level.txt +0 -0
@@ -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)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|