orionis 0.232.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.
Files changed (61) hide show
  1. orionis/framework.py +1 -1
  2. orionis/luminate/support/inspection/dependencies/contracts/__init__.py +0 -0
  3. orionis/luminate/support/inspection/dependencies/contracts/reflect_dependencies.py +43 -0
  4. orionis/luminate/support/inspection/dependencies/entities/__init__.py +0 -0
  5. orionis/luminate/support/inspection/dependencies/entities/class_dependencies.py +10 -0
  6. orionis/luminate/support/inspection/dependencies/entities/method_dependencies.py +10 -0
  7. orionis/luminate/support/inspection/dependencies/entities/resolved_dependencies.py +12 -0
  8. orionis/luminate/support/inspection/dependencies/reflect_dependencies.py +176 -0
  9. orionis/luminate/support/inspection/helpers/__init__.py +0 -0
  10. orionis/luminate/support/inspection/helpers/functions.py +281 -0
  11. orionis/luminate/support/inspection/reflect_decorators.py +335 -0
  12. orionis/luminate/support/inspection/reflection.py +16 -22
  13. orionis/luminate/support/inspection/reflection_instance.py +801 -0
  14. orionis/luminate/support/inspection/reflexion_concrete_with_abstract.py +1 -1
  15. orionis/luminate/support/inspection/reflexion_instance_with_abstract.py +4 -4
  16. orionis/luminate/test/case.py +9 -0
  17. orionis/luminate/test/cases/__init__.py +0 -0
  18. orionis/luminate/test/cases/test_async.py +32 -0
  19. orionis/luminate/test/cases/test_case.py +23 -0
  20. orionis/luminate/test/cases/test_sync.py +10 -0
  21. orionis/luminate/test/core/__init__.py +0 -0
  22. orionis/luminate/test/core/contracts/__init__.py +0 -0
  23. orionis/luminate/test/{test_suite.py → core/test_suite.py} +2 -2
  24. orionis/luminate/test/{test_unit.py → core/test_unit.py} +4 -4
  25. orionis/luminate/test/entities/__init__.py +0 -0
  26. orionis/luminate/test/{test_result.py → entities/test_result.py} +2 -2
  27. orionis/luminate/test/enums/__init__.py +0 -0
  28. orionis/luminate/test/exceptions/__init__.py +0 -0
  29. orionis/luminate/test/output/__init__.py +0 -0
  30. orionis/luminate/test/{test_std_out.py → output/test_std_out.py} +1 -1
  31. orionis/luminate/test/suite.py +7 -0
  32. {orionis-0.232.0.dist-info → orionis-0.234.0.dist-info}/METADATA +1 -1
  33. {orionis-0.232.0.dist-info → orionis-0.234.0.dist-info}/RECORD +58 -38
  34. tests/example/test_example.py +1 -1
  35. tests/support/adapters/test_doct_dict.py +1 -1
  36. tests/support/async_io/test_async_coroutine.py +1 -1
  37. tests/support/environment/test_env.py +1 -1
  38. tests/support/inspection/fakes/fake_reflection_instance.py +2 -1
  39. tests/support/inspection/test_reflection_abstract.py +19 -1
  40. tests/support/inspection/test_reflection_concrete.py +1 -1
  41. tests/support/inspection/test_reflection_concrete_with_abstract.py +1 -1
  42. tests/support/inspection/test_reflection_instance.py +71 -16
  43. tests/support/inspection/test_reflection_instance_with_abstract.py +1 -1
  44. tests/support/parsers/test_exception_parser.py +1 -1
  45. tests/support/path/test_resolver.py +6 -6
  46. tests/support/patterns/test_singleton.py +1 -1
  47. tests/support/standard/test_std.py +1 -1
  48. orionis/luminate/support/inspection/functions.py +0 -263
  49. orionis/luminate/support/inspection/reflexion_instance.py +0 -527
  50. orionis/luminate/test/test_case.py +0 -62
  51. /orionis/luminate/{test/contracts → support/inspection/dependencies}/__init__.py +0 -0
  52. /orionis/luminate/support/inspection/{reflexion_abstract.py → reflect_abstract.py} +0 -0
  53. /orionis/luminate/test/{contracts → core/contracts}/test_suite.py +0 -0
  54. /orionis/luminate/test/{contracts → core/contracts}/test_unit.py +0 -0
  55. /orionis/luminate/test/{test_status.py → enums/test_status.py} +0 -0
  56. /orionis/luminate/test/{test_exception.py → exceptions/test_exception.py} +0 -0
  57. /orionis/luminate/test/{contracts → output/contracts}/test_std_out.py +0 -0
  58. {orionis-0.232.0.dist-info → orionis-0.234.0.dist-info}/LICENCE +0 -0
  59. {orionis-0.232.0.dist-info → orionis-0.234.0.dist-info}/WHEEL +0 -0
  60. {orionis-0.232.0.dist-info → orionis-0.234.0.dist-info}/entry_points.txt +0 -0
  61. {orionis-0.232.0.dist-info → orionis-0.234.0.dist-info}/top_level.txt +0 -0
@@ -1,527 +0,0 @@
1
- from typing import Any, Type, Dict, List, Tuple, Callable, Optional
2
- import inspect
3
-
4
- from orionis.luminate.support.asynchrony.async_io import AsyncIO
5
-
6
- class ReflexionInstance:
7
- """A reflection object encapsulating a class instance.
8
-
9
- Parameters
10
- ----------
11
- instance : Any
12
- The instance being reflected upon
13
-
14
- Attributes
15
- ----------
16
- _instance : Any
17
- The encapsulated instance
18
- """
19
-
20
- def __init__(self, instance: Any) -> None:
21
- """Initialize with the instance to reflect upon."""
22
- self._instance = instance
23
-
24
- def getClassName(self) -> str:
25
- """Get the name of the instance's class.
26
-
27
- Returns
28
- -------
29
- str
30
- The name of the class
31
- """
32
- return self._instance.__class__.__name__
33
-
34
- def getClass(self) -> Type:
35
- """Get the class of the instance.
36
-
37
- Returns
38
- -------
39
- Type
40
- The class object of the instance
41
- """
42
- return self._instance.__class__
43
-
44
- def getModuleName(self) -> str:
45
- """Get the name of the module where the class is defined.
46
-
47
- Returns
48
- -------
49
- str
50
- The module name
51
- """
52
- return self._instance.__class__.__module__
53
-
54
- def getAttributes(self) -> Dict[str, Any]:
55
- """Get all attributes of the instance.
56
-
57
- Returns
58
- -------
59
- Dict[str, Any]
60
- Dictionary of attribute names and their values
61
- """
62
- return vars(self._instance)
63
-
64
- def getMethods(self) -> List[str]:
65
- """Get all method names of the instance.
66
-
67
- Returns
68
- -------
69
- List[str]
70
- List of method names
71
- """
72
- class_name = self.getClassName()
73
- methods = [name for name, _ in inspect.getmembers(
74
- self._instance,
75
- predicate=inspect.ismethod
76
- )]
77
-
78
- out_methods = []
79
- for method in methods:
80
- out_methods.append(method.replace(f"_{class_name}", ""))
81
-
82
- return out_methods
83
-
84
- def getProtectedMethods(self) -> List[str]:
85
- """Get all protected method names of the instance.
86
-
87
- Returns
88
- -------
89
- List[str]
90
- List of protected method names, excluding private methods (starting with '_')
91
- """
92
- class_name = self.getClassName()
93
- methods = [name for name, _ in inspect.getmembers(
94
- self._instance,
95
- predicate=inspect.ismethod
96
- )]
97
-
98
- out_methods = []
99
- for method in methods:
100
- if method.startswith("_") and not method.startswith("__") and not method.startswith(f"_{class_name}"):
101
- out_methods.append(method)
102
-
103
- return out_methods
104
-
105
- def getPrivateMethods(self) -> List[str]:
106
- """Get all private method names of the instance.
107
-
108
- Returns
109
- -------
110
- List[str]
111
- List of private method names, excluding protected methods (starting with '_')
112
- """
113
- class_name = self.getClassName()
114
- methods = [name for name, _ in inspect.getmembers(
115
- self._instance,
116
- predicate=inspect.ismethod
117
- )]
118
-
119
- out_methods = []
120
- for method in methods:
121
- if method.startswith(f"_{class_name}"):
122
- out_methods.append(method.replace(f"_{class_name}", ""))
123
-
124
- return out_methods
125
-
126
- def getAsyncMethods(self) -> List[str]:
127
- """
128
- Get all asynchronous method names of the instance that are not static methods.
129
-
130
- Returns
131
- -------
132
- List[str]
133
- List of asynchronous method names
134
- """
135
- obj = self._instance
136
- cls = obj if inspect.isclass(obj) else obj.__class__
137
- class_name = self.getClassName()
138
- methods = [
139
- name for name, func in inspect.getmembers(obj, inspect.iscoroutinefunction)
140
- if not isinstance(inspect.getattr_static(cls, name, None), staticmethod)
141
- ]
142
-
143
- out_methods = []
144
- for method in methods:
145
- out_methods.append(method.replace(f"_{class_name}", ""))
146
-
147
- return out_methods
148
-
149
- def getSyncMethods(self) -> List[str]:
150
- """
151
- Get all synchronous method names of the instance that are not static methods.
152
-
153
- Returns
154
- -------
155
- List[str]
156
- List of synchronous method names
157
- """
158
- obj = self._instance
159
- cls = obj if inspect.isclass(obj) else obj.__class__
160
- class_name = self.getClassName()
161
- methods = [
162
- name for name, func in inspect.getmembers(obj, predicate=inspect.ismethod)
163
- if not inspect.iscoroutinefunction(func) and
164
- not isinstance(inspect.getattr_static(cls, name, None), staticmethod)
165
- ]
166
-
167
- out_methods = []
168
- for method in methods:
169
- out_methods.append(method.replace(f"_{class_name}", ""))
170
-
171
- return out_methods
172
-
173
- def getClassMethods(self) -> List[str]:
174
- """Get all class method names of the instance.
175
-
176
- Returns
177
- -------
178
- List[str]
179
- List of class method names.
180
- """
181
- return [
182
- name for name in dir(self._instance.__class__)
183
- if isinstance(inspect.getattr_static(self._instance.__class__, name), classmethod)
184
- ]
185
-
186
- def getStaticMethods(self) -> List[str]:
187
- """Get all static method names of the instance.
188
-
189
- Returns
190
- -------
191
- List[str]
192
- List of static method names.
193
- """
194
- return [
195
- name for name in dir(self._instance.__class__)
196
- if isinstance(inspect.getattr_static(self._instance.__class__, name), staticmethod)
197
- ]
198
-
199
- def getAsyncStaticMethods(self) -> List[str]:
200
- """
201
- Get all asynchronous method names of the instance that are not static methods.
202
-
203
- Returns
204
- -------
205
- List[str]
206
- List of asynchronous method names
207
- """
208
- obj = self._instance
209
- cls = obj if inspect.isclass(obj) else obj.__class__
210
- return [
211
- name for name, func in inspect.getmembers(obj, inspect.iscoroutinefunction)
212
- if isinstance(inspect.getattr_static(cls, name, None), staticmethod)
213
- ]
214
-
215
- def getSyncStaticMethods(self) -> List[str]:
216
- """
217
- Get all synchronous static method names of the instance.
218
-
219
- Returns
220
- -------
221
- List[str]
222
- List of synchronous static method names
223
- """
224
- obj = self._instance
225
- cls = obj if inspect.isclass(obj) else obj.__class__
226
- return [
227
- name for name, func in inspect.getmembers(cls, inspect.isfunction)
228
- if not inspect.iscoroutinefunction(func) and
229
- isinstance(inspect.getattr_static(cls, name, None), staticmethod)
230
- ]
231
-
232
- def getPropertyNames(self) -> List[str]:
233
- """Get all property names of the instance.
234
-
235
- Returns
236
- -------
237
- List[str]
238
- List of property names
239
- """
240
- return [name for name, _ in inspect.getmembers(
241
- self._instance.__class__,
242
- lambda x: isinstance(x, property)
243
- )]
244
-
245
- def getProperty(self, propertyName: str) -> Any:
246
- """Get the value of a property.
247
-
248
- Parameters
249
- ----------
250
- propertyName : str
251
- Name of the property
252
-
253
- Returns
254
- -------
255
- Any
256
- The value of the property
257
-
258
- Raises
259
- ------
260
- AttributeError
261
- If the property doesn't exist or is not a property
262
- """
263
- attr = getattr(self._instance.__class__, propertyName, None)
264
- if isinstance(attr, property) and attr.fget is not None:
265
- return getattr(self._instance, propertyName)
266
- raise AttributeError(f"{propertyName} is not a property or doesn't have a getter.")
267
-
268
- def getPropertySignature(self, propertyName: str) -> inspect.Signature:
269
- """Get the signature of a property.
270
-
271
- Parameters
272
- ----------
273
- propertyName : str
274
- Name of the property
275
-
276
- Returns
277
- -------
278
- inspect.Signature
279
- The property signature
280
-
281
- Raises
282
- ------
283
- AttributeError
284
- If the property doesn't exist or is not a property
285
- """
286
- attr = getattr(self._instance.__class__, propertyName, None)
287
- if isinstance(attr, property) and attr.fget is not None:
288
- return inspect.signature(attr.fget)
289
- raise AttributeError(f"{propertyName} is not a property or doesn't have a getter.")
290
-
291
- def callMethod(self, methodName: str, *args: Any, **kwargs: Any) -> Any:
292
- """Call a method on the instance.
293
-
294
- Parameters
295
- ----------
296
- methodName : str
297
- Name of the method to call
298
- *args : Any
299
- Positional arguments for the method
300
- **kwargs : Any
301
- Keyword arguments for the method
302
-
303
- Returns
304
- -------
305
- Any
306
- The result of the method call
307
-
308
- Raises
309
- ------
310
- AttributeError
311
- If the method does not exist on the instance
312
- TypeError
313
- If the method is not callable
314
- """
315
-
316
- if methodName in self.getPrivateMethods():
317
- methodName = f"_{self.getClassName()}{methodName}"
318
-
319
- method = getattr(self._instance, methodName, None)
320
-
321
- if method is None:
322
- raise AttributeError(f"'{self.getClassName()}' object has no method '{methodName}'.")
323
- if not callable(method):
324
- raise TypeError(f"'{methodName}' is not callable on '{self.getClassName()}'.")
325
-
326
- if inspect.iscoroutinefunction(method):
327
- return AsyncIO.run(method(*args, **kwargs))
328
-
329
- return method(*args, **kwargs)
330
-
331
- def getMethodSignature(self, methodName: str) -> inspect.Signature:
332
- """Get the signature of a method.
333
-
334
- Parameters
335
- ----------
336
- methodName : str
337
- Name of the method
338
-
339
- Returns
340
- -------
341
- inspect.Signature
342
- The method signature
343
- """
344
- if methodName in self.getPrivateMethods():
345
- methodName = f"_{self.getClassName()}{methodName}"
346
-
347
- method = getattr(self._instance, methodName)
348
- if callable(method):
349
- return inspect.signature(method)
350
-
351
- def getDocstring(self) -> Optional[str]:
352
- """Get the docstring of the instance's class.
353
-
354
- Returns
355
- -------
356
- Optional[str]
357
- The class docstring, or None if not available
358
- """
359
- return self._instance.__class__.__doc__
360
-
361
- def getBaseClasses(self) -> Tuple[Type, ...]:
362
- """Get the base classes of the instance's class.
363
-
364
- Returns
365
- -------
366
- Tuple[Type, ...]
367
- Tuple of base classes
368
- """
369
- return self._instance.__class__.__bases__
370
-
371
- def isInstanceOf(self, cls: Type) -> bool:
372
- """Check if the instance is of a specific class.
373
-
374
- Parameters
375
- ----------
376
- cls : Type
377
- The class to check against
378
-
379
- Returns
380
- -------
381
- bool
382
- True if the instance is of the specified class
383
- """
384
- return isinstance(self._instance, cls)
385
-
386
- def getSourceCode(self) -> Optional[str]:
387
- """Get the source code of the instance's class.
388
-
389
- Returns
390
- -------
391
- Optional[str]
392
- The source code if available, None otherwise
393
- """
394
- try:
395
- return inspect.getsource(self._instance.__class__)
396
- except (TypeError, OSError):
397
- return None
398
-
399
- def getFileLocation(self) -> Optional[str]:
400
- """Get the file location where the class is defined.
401
-
402
- Returns
403
- -------
404
- Optional[str]
405
- The file path if available, None otherwise
406
- """
407
- try:
408
- return inspect.getfile(self._instance.__class__)
409
- except (TypeError, OSError):
410
- return None
411
-
412
- def getAnnotations(self) -> Dict[str, Any]:
413
- """Get type annotations of the class.
414
-
415
- Returns
416
- -------
417
- Dict[str, Any]
418
- Dictionary of attribute names and their type annotations
419
- """
420
- return self._instance.__class__.__annotations__
421
-
422
- def hasAttribute(self, name: str) -> bool:
423
- """Check if the instance has a specific attribute.
424
-
425
- Parameters
426
- ----------
427
- name : str
428
- The attribute name to check
429
-
430
- Returns
431
- -------
432
- bool
433
- True if the attribute exists
434
- """
435
- return hasattr(self._instance, name)
436
-
437
- def getAttribute(self, name: str) -> Any:
438
- """Get an attribute value by name.
439
-
440
- Parameters
441
- ----------
442
- name : str
443
- The attribute name
444
-
445
- Returns
446
- -------
447
- Any
448
- The attribute value
449
-
450
- Raises
451
- ------
452
- AttributeError
453
- If the attribute doesn't exist
454
- """
455
- return getattr(self._instance, name)
456
-
457
- def setAttribute(self, name: str, value: Any) -> None:
458
- """Set an attribute value.
459
-
460
- Parameters
461
- ----------
462
- name : str
463
- The attribute name
464
- value : Any
465
- The value to set
466
-
467
- Raises
468
- ------
469
- AttributeError
470
- If the attribute is read-only
471
- """
472
- if callable(value):
473
- raise AttributeError(f"Cannot set attribute '{name}' to a callable.")
474
- setattr(self._instance, name, value)
475
-
476
- def removeAttribute(self, name: str) -> None:
477
- """Remove an attribute from the instance.
478
-
479
- Parameters
480
- ----------
481
- name : str
482
- The attribute name to remove
483
-
484
- Raises
485
- ------
486
- AttributeError
487
- If the attribute doesn't exist or is read-only
488
- """
489
- if not hasattr(self._instance, name):
490
- raise AttributeError(f"'{self.getClassName()}' object has no attribute '{name}'.")
491
- delattr(self._instance, name)
492
-
493
- def setMacro(self, name: str, value: Callable) -> None:
494
- """Set a callable attribute value.
495
-
496
- Parameters
497
- ----------
498
- name : str
499
- The attribute name
500
- value : Callable
501
- The callable to set
502
-
503
- Raises
504
- ------
505
- AttributeError
506
- If the value is not callable
507
- """
508
- if not callable(value):
509
- raise AttributeError(f"The value for '{name}' must be a callable.")
510
- setattr(self._instance, name, value)
511
-
512
- def removeMacro(self, name: str) -> None:
513
- """Remove a callable attribute from the instance.
514
-
515
- Parameters
516
- ----------
517
- name : str
518
- The attribute name to remove
519
-
520
- Raises
521
- ------
522
- AttributeError
523
- If the attribute doesn't exist or is not callable
524
- """
525
- if not hasattr(self._instance, name) or not callable(getattr(self._instance, name)):
526
- raise AttributeError(f"'{self.getClassName()}' object has no callable macro '{name}'.")
527
- delattr(self._instance, name)
@@ -1,62 +0,0 @@
1
- import unittest
2
- from orionis.luminate.test.test_std_out import TestStdOut
3
-
4
- class TestCase(unittest.IsolatedAsyncioTestCase, TestStdOut):
5
- """
6
- TestCase is a base class for unit tests that provides support for asynchronous
7
- testing using `unittest.IsolatedAsyncioTestCase` and additional functionality
8
- from `TestStdOut`."""
9
- async def asyncSetUp(self):
10
- """
11
- Asynchronous setup method called before each test.
12
- It ensures that the parent class's asyncSetUp method is invoked to initialize
13
- any required resources.
14
- """
15
- await super().asyncSetUp()
16
-
17
- async def asyncTearDown(self):
18
- """
19
- Asynchronous teardown method called after each test.
20
- It ensures that the parent class's asyncTearDown method is invoked to clean up
21
- any resources used during the test.
22
- """
23
- await super().asyncTearDown()
24
-
25
- # Another asynchronous test case class
26
- class AsyncTestCase(unittest.IsolatedAsyncioTestCase, TestStdOut):
27
- """
28
- AsyncTestCase is a test case class designed for asynchronous unit testing.
29
- It inherits from `unittest.IsolatedAsyncioTestCase` to provide support for
30
- async test methods and `TestStdOut` for additional functionality.
31
- Methods
32
- -------
33
- asyncSetUp()
34
- Asynchronous setup method called before each test. It ensures that the
35
- parent class's asyncSetUp method is invoked to initialize any required
36
- resources.
37
- asyncTearDown()
38
- Asynchronous teardown method called after each test. It ensures that the
39
- parent class's asyncTearDown method is invoked to clean up any resources
40
- used during the test.
41
- """
42
- async def asyncSetUp(self):
43
- """
44
- Asynchronous setup method called before each test.
45
- It ensures that the parent class's asyncSetUp method is invoked to initialize
46
- """
47
- await super().asyncSetUp()
48
-
49
- async def asyncTearDown(self):
50
- """
51
- Asynchronous teardown method called after each test.
52
- It ensures that the parent class's asyncTearDown method is invoked to clean up
53
- """
54
- await super().asyncTearDown()
55
-
56
- class SyncTestCase(unittest.TestCase, TestStdOut):
57
- """
58
- SyncTestCase is a test case class designed for synchronous unit testing.
59
- It inherits from `unittest.TestCase` to provide support for standard test methods
60
- and `TestStdOut` for additional functionality.
61
- """
62
- pass