orionis 0.233.0__py3-none-any.whl → 0.234.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- orionis/framework.py +1 -1
- orionis/luminate/support/inspection/dependencies/contracts/__init__.py +0 -0
- orionis/luminate/support/inspection/dependencies/contracts/reflect_dependencies.py +43 -0
- orionis/luminate/support/inspection/dependencies/entities/__init__.py +0 -0
- orionis/luminate/support/inspection/dependencies/entities/class_dependencies.py +10 -0
- orionis/luminate/support/inspection/dependencies/entities/method_dependencies.py +10 -0
- orionis/luminate/support/inspection/dependencies/entities/resolved_dependencies.py +12 -0
- orionis/luminate/support/inspection/dependencies/reflect_dependencies.py +176 -0
- orionis/luminate/support/inspection/helpers/__init__.py +0 -0
- orionis/luminate/support/inspection/helpers/functions.py +281 -0
- orionis/luminate/support/inspection/reflect_decorators.py +335 -0
- orionis/luminate/support/inspection/reflection.py +16 -22
- orionis/luminate/support/inspection/reflection_instance.py +801 -0
- orionis/luminate/support/inspection/reflexion_concrete_with_abstract.py +1 -1
- orionis/luminate/support/inspection/reflexion_instance_with_abstract.py +4 -4
- orionis/luminate/test/case.py +9 -0
- orionis/luminate/test/cases/__init__.py +0 -0
- orionis/luminate/test/cases/test_async.py +32 -0
- orionis/luminate/test/cases/test_case.py +23 -0
- orionis/luminate/test/cases/test_sync.py +10 -0
- orionis/luminate/test/core/__init__.py +0 -0
- orionis/luminate/test/core/contracts/__init__.py +0 -0
- orionis/luminate/test/{test_suite.py → core/test_suite.py} +2 -2
- orionis/luminate/test/{test_unit.py → core/test_unit.py} +4 -4
- orionis/luminate/test/entities/__init__.py +0 -0
- orionis/luminate/test/{test_result.py → entities/test_result.py} +2 -2
- orionis/luminate/test/enums/__init__.py +0 -0
- orionis/luminate/test/exceptions/__init__.py +0 -0
- orionis/luminate/test/output/__init__.py +0 -0
- orionis/luminate/test/{test_std_out.py → output/test_std_out.py} +1 -1
- orionis/luminate/test/suite.py +7 -0
- {orionis-0.233.0.dist-info → orionis-0.234.0.dist-info}/METADATA +1 -1
- {orionis-0.233.0.dist-info → orionis-0.234.0.dist-info}/RECORD +57 -37
- tests/example/test_example.py +1 -1
- tests/support/adapters/test_doct_dict.py +1 -1
- tests/support/async_io/test_async_coroutine.py +1 -1
- tests/support/environment/test_env.py +1 -1
- tests/support/inspection/test_reflection_abstract.py +19 -1
- tests/support/inspection/test_reflection_concrete.py +1 -1
- tests/support/inspection/test_reflection_concrete_with_abstract.py +1 -1
- tests/support/inspection/test_reflection_instance.py +40 -15
- tests/support/inspection/test_reflection_instance_with_abstract.py +1 -1
- tests/support/parsers/test_exception_parser.py +1 -1
- tests/support/path/test_resolver.py +6 -6
- tests/support/patterns/test_singleton.py +1 -1
- tests/support/standard/test_std.py +1 -1
- orionis/luminate/support/inspection/functions.py +0 -263
- orionis/luminate/support/inspection/reflexion_instance.py +0 -580
- orionis/luminate/test/test_case.py +0 -62
- /orionis/luminate/{test/contracts → support/inspection/dependencies}/__init__.py +0 -0
- /orionis/luminate/support/inspection/{reflexion_abstract.py → reflect_abstract.py} +0 -0
- /orionis/luminate/test/{contracts → core/contracts}/test_suite.py +0 -0
- /orionis/luminate/test/{contracts → core/contracts}/test_unit.py +0 -0
- /orionis/luminate/test/{test_status.py → enums/test_status.py} +0 -0
- /orionis/luminate/test/{test_exception.py → exceptions/test_exception.py} +0 -0
- /orionis/luminate/test/{contracts → output/contracts}/test_std_out.py +0 -0
- {orionis-0.233.0.dist-info → orionis-0.234.0.dist-info}/LICENCE +0 -0
- {orionis-0.233.0.dist-info → orionis-0.234.0.dist-info}/WHEEL +0 -0
- {orionis-0.233.0.dist-info → orionis-0.234.0.dist-info}/entry_points.txt +0 -0
- {orionis-0.233.0.dist-info → orionis-0.234.0.dist-info}/top_level.txt +0 -0
@@ -1,263 +0,0 @@
|
|
1
|
-
from typing import Any, Type
|
2
|
-
import inspect
|
3
|
-
import importlib
|
4
|
-
|
5
|
-
def _is_valid_module(module_name: str) -> bool:
|
6
|
-
"""Check if a module name is valid and can be imported.
|
7
|
-
|
8
|
-
Parameters
|
9
|
-
----------
|
10
|
-
module_name : str
|
11
|
-
The name of the module to check
|
12
|
-
|
13
|
-
Returns
|
14
|
-
-------
|
15
|
-
bool
|
16
|
-
True if the module is valid and can be imported, False otherwise
|
17
|
-
"""
|
18
|
-
try:
|
19
|
-
importlib.import_module(module_name)
|
20
|
-
return True
|
21
|
-
except ImportError:
|
22
|
-
return False
|
23
|
-
|
24
|
-
def _ensure_valid_module(module_name: str) -> None:
|
25
|
-
"""Ensure a module name is valid and can be imported.
|
26
|
-
|
27
|
-
Parameters
|
28
|
-
----------
|
29
|
-
module_name : str
|
30
|
-
The name of the module to check
|
31
|
-
|
32
|
-
Raises
|
33
|
-
------
|
34
|
-
ValueError
|
35
|
-
If the module cannot be imported or is invalid
|
36
|
-
"""
|
37
|
-
if not isinstance(module_name, str):
|
38
|
-
raise TypeError(f"Module name must be a string, got {type(module_name)}")
|
39
|
-
if not _is_valid_module(module_name):
|
40
|
-
raise ValueError(f"Invalid or non-importable module: {module_name}")
|
41
|
-
|
42
|
-
def _is_instantiable_class(cls: Type) -> bool:
|
43
|
-
"""Check if a class is concrete and can be instantiated.
|
44
|
-
|
45
|
-
Parameters
|
46
|
-
----------
|
47
|
-
cls : Type
|
48
|
-
The class to check
|
49
|
-
|
50
|
-
Returns
|
51
|
-
--
|
52
|
-
bool
|
53
|
-
True if the class is concrete and can be instantiated, False otherwise
|
54
|
-
"""
|
55
|
-
if not isinstance(cls, type):
|
56
|
-
return False
|
57
|
-
if _is_abstract_class(cls):
|
58
|
-
return False
|
59
|
-
try:
|
60
|
-
# Try to create an instance to verify it's truly concrete
|
61
|
-
cls()
|
62
|
-
return True
|
63
|
-
except TypeError:
|
64
|
-
return False
|
65
|
-
|
66
|
-
def _ensure_not_builtin_type(cls: Type) -> None:
|
67
|
-
"""Ensure a class is not a built-in or primitive type.
|
68
|
-
|
69
|
-
Parameters
|
70
|
-
----------
|
71
|
-
cls : Type
|
72
|
-
The class to check
|
73
|
-
|
74
|
-
Raises
|
75
|
-
------
|
76
|
-
TypeError
|
77
|
-
If the input is not a class
|
78
|
-
ValueError
|
79
|
-
If the class is a built-in or primitive type
|
80
|
-
"""
|
81
|
-
if not isinstance(cls, type):
|
82
|
-
raise TypeError(f"Expected a class, got {type(cls)}")
|
83
|
-
|
84
|
-
builtin_types = {
|
85
|
-
int, float, str, bool, bytes, type(None), complex,
|
86
|
-
list, tuple, dict, set, frozenset
|
87
|
-
}
|
88
|
-
|
89
|
-
if cls in builtin_types:
|
90
|
-
raise ValueError(f"Class '{cls.__name__}' is a built-in or primitive type and cannot be used.")
|
91
|
-
|
92
|
-
def _ensure_instantiable_class(cls: Type) -> None:
|
93
|
-
"""Ensure a class is concrete and can be instantiated.
|
94
|
-
|
95
|
-
Parameters
|
96
|
-
----------
|
97
|
-
cls : Type
|
98
|
-
The class to check
|
99
|
-
|
100
|
-
Raises
|
101
|
-
------
|
102
|
-
TypeError
|
103
|
-
If the input is not a class
|
104
|
-
ValueError
|
105
|
-
If the class is abstract or cannot be instantiated
|
106
|
-
"""
|
107
|
-
if _ensure_not_builtin_type(cls):
|
108
|
-
raise TypeError(f"Invalid class: {cls!r}")
|
109
|
-
if not isinstance(cls, type):
|
110
|
-
raise TypeError(f"Expected a class, got {type(cls)}")
|
111
|
-
if _is_abstract_class(cls):
|
112
|
-
raise ValueError(f"Class '{cls.__name__}' is abstract")
|
113
|
-
try:
|
114
|
-
cls()
|
115
|
-
except TypeError as e:
|
116
|
-
raise ValueError(f"Class '{cls.__name__}' cannot be instantiated: {str(e)}")
|
117
|
-
|
118
|
-
def _is_valid_class_name(module_name: str, class_name: str) -> bool:
|
119
|
-
"""Check if a class exists in a given module.
|
120
|
-
|
121
|
-
Parameters
|
122
|
-
----------
|
123
|
-
module_name : str
|
124
|
-
The name of the module to check
|
125
|
-
class_name : str
|
126
|
-
The name of the class to look for
|
127
|
-
|
128
|
-
Returns
|
129
|
-
-------
|
130
|
-
bool
|
131
|
-
True if the class exists in the module, False otherwise
|
132
|
-
"""
|
133
|
-
try:
|
134
|
-
module = importlib.import_module(module_name)
|
135
|
-
return hasattr(module, class_name) and inspect.isclass(getattr(module, class_name))
|
136
|
-
except ImportError:
|
137
|
-
return False
|
138
|
-
|
139
|
-
def _ensure_valid_class_name(module_name: str, class_name: str) -> None:
|
140
|
-
"""Ensure a class exists in a given module.
|
141
|
-
|
142
|
-
Parameters
|
143
|
-
----------
|
144
|
-
module_name : str
|
145
|
-
The name of the module to check
|
146
|
-
class_name : str
|
147
|
-
The name of the class to look for
|
148
|
-
|
149
|
-
Raises
|
150
|
-
------
|
151
|
-
ValueError
|
152
|
-
If the class doesn't exist in the module
|
153
|
-
"""
|
154
|
-
if not _is_valid_class_name(module_name, class_name):
|
155
|
-
raise ValueError(f"Class '{class_name}' not found in module '{module_name}'")
|
156
|
-
|
157
|
-
def _is_user_defined_class_instance(instance: Any) -> bool:
|
158
|
-
"""Check if an object is an instance of a user-defined class.
|
159
|
-
|
160
|
-
Parameters
|
161
|
-
----------
|
162
|
-
instance : Any
|
163
|
-
The object to check
|
164
|
-
|
165
|
-
Returns
|
166
|
-
-------
|
167
|
-
bool
|
168
|
-
True if the object is an instance of a user-defined class, False otherwise
|
169
|
-
"""
|
170
|
-
return isinstance(instance, object) and type(instance).__module__ not in {'builtins', 'abc', '__main__'}
|
171
|
-
|
172
|
-
def _ensure_user_defined_class_instance(instance: Any) -> None:
|
173
|
-
"""Ensure an object is an instance of a user-defined class.
|
174
|
-
|
175
|
-
Parameters
|
176
|
-
----------
|
177
|
-
instance : Any
|
178
|
-
The object to check
|
179
|
-
|
180
|
-
Raises
|
181
|
-
------
|
182
|
-
TypeError
|
183
|
-
If the input is not an object instance
|
184
|
-
ValueError
|
185
|
-
If the instance is from builtins, abc, or __main__
|
186
|
-
"""
|
187
|
-
if not isinstance(instance, object):
|
188
|
-
raise TypeError(f"Invalid object: {instance!r}")
|
189
|
-
module = type(instance).__module__
|
190
|
-
if module in {'builtins', 'abc'}:
|
191
|
-
raise ValueError(f"'{instance!r}' is not a user-defined class instance, belongs to '{module}'.")
|
192
|
-
if module == '__main__':
|
193
|
-
raise ValueError("Instance originates from '__main__', origin indeterminate.")
|
194
|
-
|
195
|
-
def _is_abstract_class(cls: Type) -> bool:
|
196
|
-
"""Check if a class is abstract.
|
197
|
-
|
198
|
-
Parameters
|
199
|
-
----------
|
200
|
-
cls : Type
|
201
|
-
The class to check
|
202
|
-
|
203
|
-
Returns
|
204
|
-
-------
|
205
|
-
bool
|
206
|
-
True if the class is abstract, False otherwise
|
207
|
-
"""
|
208
|
-
return isinstance(cls, type) and bool(getattr(cls, '__abstractmethods__', False))
|
209
|
-
|
210
|
-
def _ensure_abstract_class(cls: Type) -> None:
|
211
|
-
"""Ensure a class is abstract.
|
212
|
-
|
213
|
-
Parameters
|
214
|
-
----------
|
215
|
-
cls : Type
|
216
|
-
The class to check
|
217
|
-
|
218
|
-
Raises
|
219
|
-
------
|
220
|
-
TypeError
|
221
|
-
If the input is not a class
|
222
|
-
ValueError
|
223
|
-
If the class is not abstract
|
224
|
-
"""
|
225
|
-
if not isinstance(cls, type):
|
226
|
-
raise TypeError(f"Invalid class: {cls!r}")
|
227
|
-
if not _is_abstract_class(cls):
|
228
|
-
raise ValueError(f"Class '{cls.__name__}' is not abstract.")
|
229
|
-
|
230
|
-
def _is_concrete_class(cls: Type) -> bool:
|
231
|
-
"""Check if a class is concrete.
|
232
|
-
|
233
|
-
Parameters
|
234
|
-
----------
|
235
|
-
cls : Type
|
236
|
-
The class to check
|
237
|
-
|
238
|
-
Returns
|
239
|
-
-------
|
240
|
-
bool
|
241
|
-
True if the class is concrete, False otherwise
|
242
|
-
"""
|
243
|
-
return isinstance(cls, type) and not _is_abstract_class(cls)
|
244
|
-
|
245
|
-
def _ensure_concrete_class(cls: Type) -> None:
|
246
|
-
"""Ensure a class is concrete.
|
247
|
-
|
248
|
-
Parameters
|
249
|
-
----------
|
250
|
-
cls : Type
|
251
|
-
The class to check
|
252
|
-
|
253
|
-
Raises
|
254
|
-
------
|
255
|
-
TypeError
|
256
|
-
If the input is not a class
|
257
|
-
ValueError
|
258
|
-
If the class is not concrete
|
259
|
-
"""
|
260
|
-
if not isinstance(cls, type):
|
261
|
-
raise TypeError(f"Invalid class: {cls!r}")
|
262
|
-
if not _is_concrete_class(cls):
|
263
|
-
raise ValueError(f"Class '{cls.__name__}' is not concrete.")
|