orionis 0.239.0__py3-none-any.whl → 0.240.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 (21) hide show
  1. orionis/framework.py +1 -1
  2. orionis/luminate/support/introspection/__init__.py +1 -2
  3. orionis/luminate/support/introspection/abstracts/__init__.py +0 -0
  4. orionis/luminate/support/introspection/{reflect_abstract.py → abstracts/reflect_abstract.py} +66 -2
  5. orionis/luminate/support/introspection/contracts/reflexion_abstract.py +0 -1
  6. orionis/luminate/support/introspection/instances/contracts/__init__.py +0 -0
  7. orionis/luminate/support/introspection/instances/contracts/reflection_instance.py +644 -0
  8. orionis/luminate/support/introspection/instances/reflection_instance.py +4 -1
  9. orionis/luminate/support/introspection/reflection.py +1 -1
  10. orionis/luminate/support/introspection/reflexion_concrete_with_abstract.py +1 -1
  11. orionis/luminate/support/introspection/reflexion_instance_with_abstract.py +1 -1
  12. {orionis-0.239.0.dist-info → orionis-0.240.0.dist-info}/METADATA +1 -1
  13. {orionis-0.239.0.dist-info → orionis-0.240.0.dist-info}/RECORD +20 -17
  14. tests/support/inspection/fakes/{fake_reflection_abstract.py → fake_reflect_abstract.py} +2 -0
  15. tests/support/inspection/test_reflect_abstract.py +273 -0
  16. tests/support/inspection/test_reflect_instance.py +1 -0
  17. tests/support/inspection/test_reflection_abstract.py +0 -255
  18. {orionis-0.239.0.dist-info → orionis-0.240.0.dist-info}/LICENCE +0 -0
  19. {orionis-0.239.0.dist-info → orionis-0.240.0.dist-info}/WHEEL +0 -0
  20. {orionis-0.239.0.dist-info → orionis-0.240.0.dist-info}/entry_points.txt +0 -0
  21. {orionis-0.239.0.dist-info → orionis-0.240.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,644 @@
1
+ from abc import ABC, abstractmethod
2
+ import inspect
3
+ from typing import Any, Callable, Dict, List, Optional, Tuple, Type
4
+
5
+ class IReflectionInstance(ABC):
6
+ """
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
+ @abstractmethod
21
+ def parse(self):
22
+ """
23
+ Parse the instance into a structured representation.
24
+
25
+ This method extracts and organizes various details about the instance,
26
+ including its class name, module, attributes, methods, and properties,
27
+ into a `ClassParsed` object.
28
+
29
+ Returns
30
+ -------
31
+ ClassParsed
32
+ A structured representation of the instance, containing:
33
+ - name: The name of the instance's class.
34
+ - module: The module where the class is defined.
35
+ - attributes: Categorized attributes (public, private, protected).
36
+ - methods: Categorized methods (public, private, protected, static, etc.).
37
+ - properties: A dictionary of properties with their details.
38
+ """
39
+ pass
40
+
41
+ @abstractmethod
42
+ def getClassName(self) -> str:
43
+ """
44
+ Get the name of the instance's class.
45
+
46
+ Returns
47
+ -------
48
+ str
49
+ The name of the class
50
+ """
51
+ pass
52
+
53
+ @abstractmethod
54
+ def getClass(self) -> Type:
55
+ """
56
+ Get the class of the instance.
57
+
58
+ Returns
59
+ -------
60
+ Type
61
+ The class object of the instance
62
+ """
63
+ pass
64
+
65
+ @abstractmethod
66
+ def getModuleName(self) -> str:
67
+ """
68
+ Get the name of the module where the class is defined.
69
+
70
+ Returns
71
+ -------
72
+ str
73
+ The module name
74
+ """
75
+ pass
76
+
77
+ @abstractmethod
78
+ def getAllAttributes(self):
79
+ """
80
+ Get all attributes of the instance.
81
+
82
+ Returns
83
+ -------
84
+ Dict[str, Any]
85
+ Dictionary of attribute names and their values
86
+ """
87
+ pass
88
+
89
+ @abstractmethod
90
+ def getAttributes(self) -> Dict[str, Any]:
91
+ """
92
+ Get all attributes of the instance.
93
+
94
+ Returns
95
+ -------
96
+ Dict[str, Any]
97
+ Dictionary of attribute names and their values
98
+ """
99
+ pass
100
+
101
+ @abstractmethod
102
+ def getPublicAttributes(self) -> Dict[str, Any]:
103
+ """
104
+ Get all public attributes of the instance.
105
+
106
+ Returns
107
+ -------
108
+ Dict[str, Any]
109
+ Dictionary of public attribute names and their values
110
+ """
111
+ pass
112
+
113
+ @abstractmethod
114
+ def getPrivateAttributes(self) -> Dict[str, Any]:
115
+ """
116
+ Get all private attributes of the instance.
117
+
118
+ Returns
119
+ -------
120
+ Dict[str, Any]
121
+ Dictionary of private attribute names and their values
122
+ """
123
+ pass
124
+
125
+ @abstractmethod
126
+ def getProtectedAttributes(self) -> Dict[str, Any]:
127
+ """
128
+ Get all Protected attributes of the instance.
129
+
130
+ Returns
131
+ -------
132
+ Dict[str, Any]
133
+ Dictionary of Protected attribute names and their values
134
+ """
135
+ pass
136
+
137
+ @abstractmethod
138
+ def getAllMethods(self):
139
+ """
140
+ Retrieves and categorizes all methods of the instance's class into various classifications.
141
+ This method inspects the instance's class and its methods, categorizing them into public, private,
142
+ protected, static, asynchronous, synchronous, class methods, asynchronous static, synchronous static,
143
+ and magic methods.
144
+ Returns
145
+ -------
146
+ ClassMethod
147
+ An object containing categorized lists of method names:
148
+ - public: List of public instance methods.
149
+ - private: List of private instance methods (names without the class prefix).
150
+ - protected: List of protected instance methods.
151
+ - static: List of static methods.
152
+ - asynchronous: List of asynchronous instance methods.
153
+ - synchronous: List of synchronous instance methods.
154
+ - class_methods: List of class methods.
155
+ - asynchronous_static: List of asynchronous static methods.
156
+ - synchronous_static: List of synchronous static methods.
157
+ - magic: List of magic methods (e.g., `__init__`, `__str__`).
158
+ Notes
159
+ -----
160
+ - Magic methods are identified by their double underscore prefix and suffix (e.g., `__init__`).
161
+ - Private methods are identified by a single underscore followed by the class name.
162
+ - Protected methods are identified by a single underscore prefix.
163
+ - Public methods are identified as methods without any leading underscores.
164
+ - Static and class methods are identified using `inspect.getattr_static`.
165
+ - Asynchronous methods are identified using `inspect.iscoroutinefunction`.
166
+ - Synchronous methods are identified as methods that are not asynchronous, static, or class methods.
167
+ """
168
+ pass
169
+
170
+ @abstractmethod
171
+ def getMethods(self) -> List[str]:
172
+ """
173
+ Get all method names of the instance.
174
+
175
+ Returns
176
+ -------
177
+ List[str]
178
+ List of method names
179
+ """
180
+ pass
181
+
182
+ @abstractmethod
183
+ def getProtectedMethods(self) -> List[str]:
184
+ """
185
+ Get all protected method names of the instance.
186
+
187
+ Returns
188
+ -------
189
+ List[str]
190
+ List of protected method names, excluding private methods (starting with '_')
191
+ """
192
+ pass
193
+
194
+ @abstractmethod
195
+ def getPrivateMethods(self) -> List[str]:
196
+ """
197
+ Get all private method names of the instance.
198
+
199
+ Returns
200
+ -------
201
+ List[str]
202
+ List of private method names, excluding protected methods (starting with '_')
203
+ """
204
+ pass
205
+
206
+ @abstractmethod
207
+ def getStaticMethods(self) -> List[str]:
208
+ """
209
+ Get all static method names of the instance.
210
+
211
+ Returns
212
+ -------
213
+ List[str]
214
+ List of static method names.
215
+ """
216
+ pass
217
+
218
+ @abstractmethod
219
+ def getAsyncMethods(self) -> List[str]:
220
+ """
221
+ Get all asynchronous method names of the instance that are not static methods.
222
+
223
+ Returns
224
+ -------
225
+ List[str]
226
+ List of asynchronous method names
227
+ """
228
+ pass
229
+
230
+ @abstractmethod
231
+ def getSyncMethods(self) -> List[str]:
232
+ """
233
+ Get all synchronous method names of the instance that are not static methods.
234
+
235
+ Returns
236
+ -------
237
+ List[str]
238
+ List of synchronous method names
239
+ """
240
+ pass
241
+
242
+ @abstractmethod
243
+ def getClassMethods(self) -> List[str]:
244
+ """
245
+ Get all class method names of the instance.
246
+
247
+ Returns
248
+ -------
249
+ List[str]
250
+ List of class method names.
251
+ """
252
+ pass
253
+
254
+ @abstractmethod
255
+ def getAsyncStaticMethods(self) -> List[str]:
256
+ """
257
+ Get all asynchronous method names of the instance that are not static methods.
258
+
259
+ Returns
260
+ -------
261
+ List[str]
262
+ List of asynchronous method names
263
+ """
264
+ pass
265
+
266
+ @abstractmethod
267
+ def getSyncStaticMethods(self) -> List[str]:
268
+ """
269
+ Get all synchronous static method names of the instance.
270
+
271
+ Returns
272
+ -------
273
+ List[str]
274
+ List of synchronous static method names
275
+ """
276
+ pass
277
+
278
+ @abstractmethod
279
+ def getMagicMethods(self) -> List[str]:
280
+ """
281
+ Get all magic method names of the instance.
282
+
283
+ Returns
284
+ -------
285
+ List[str]
286
+ List of magic method names
287
+ """
288
+ pass
289
+
290
+ @abstractmethod
291
+ def getAllProperties(self) -> Dict[str, Any]:
292
+ """
293
+ Get all properties of the instance.
294
+
295
+ Returns
296
+ -------
297
+ List[str]
298
+ List of property names
299
+ """
300
+ pass
301
+
302
+ @abstractmethod
303
+ def getPropertyNames(self) -> List[str]:
304
+ """
305
+ Get all property names of the instance.
306
+
307
+ Returns
308
+ -------
309
+ List[str]
310
+ List of property names
311
+ """
312
+ pass
313
+
314
+ @abstractmethod
315
+ def getProperty(self, property_name: str) -> Any:
316
+ """
317
+ Get the value of a property.
318
+
319
+ Parameters
320
+ ----------
321
+ property_name : str
322
+ Name of the property
323
+
324
+ Returns
325
+ -------
326
+ Any
327
+ The value of the property
328
+
329
+ Raises
330
+ ------
331
+ AttributeError
332
+ If the property doesn't exist or is not a property
333
+ """
334
+ pass
335
+
336
+ @abstractmethod
337
+ def getPropertySignature(self, property_name: str) -> inspect.Signature:
338
+ """
339
+ Get the signature of a property.
340
+
341
+ Parameters
342
+ ----------
343
+ property_name : str
344
+ Name of the property
345
+
346
+ Returns
347
+ -------
348
+ inspect.Signature
349
+ The property signature
350
+
351
+ Raises
352
+ ------
353
+ AttributeError
354
+ If the property doesn't exist or is not a property
355
+ """
356
+ pass
357
+
358
+ @abstractmethod
359
+ def getPropertyDoc(self, property_name: str) -> str:
360
+ """
361
+ Get the docstring of a property.
362
+
363
+ Parameters
364
+ ----------
365
+ property_name : str
366
+ Name of the property
367
+
368
+ Returns
369
+ -------
370
+ str
371
+ The docstring of the property
372
+
373
+ Raises
374
+ ------
375
+ AttributeError
376
+ If the property doesn't exist or is not a property
377
+ """
378
+ pass
379
+
380
+ @abstractmethod
381
+ def callMethod(self, method_name: str, *args: Any, **kwargs: Any) -> Any:
382
+ """
383
+ Call a method on the instance.
384
+
385
+ Parameters
386
+ ----------
387
+ method_name : str
388
+ Name of the method to call
389
+ *args : Any
390
+ Positional arguments for the method
391
+ **kwargs : Any
392
+ Keyword arguments for the method
393
+
394
+ Returns
395
+ -------
396
+ Any
397
+ The result of the method call
398
+
399
+ Raises
400
+ ------
401
+ AttributeError
402
+ If the method does not exist on the instance
403
+ TypeError
404
+ If the method is not callable
405
+ """
406
+ pass
407
+
408
+ @abstractmethod
409
+ def getMethodSignature(self, method_name: str) -> inspect.Signature:
410
+ """
411
+ Get the signature of a method.
412
+
413
+ Parameters
414
+ ----------
415
+ method_name : str
416
+ Name of the method
417
+
418
+ Returns
419
+ -------
420
+ inspect.Signature
421
+ The method signature
422
+ """
423
+ pass
424
+
425
+ @abstractmethod
426
+ def getDocstring(self) -> Optional[str]:
427
+ """
428
+ Get the docstring of the instance's class.
429
+
430
+ Returns
431
+ -------
432
+ Optional[str]
433
+ The class docstring, or None if not available
434
+ """
435
+ pass
436
+
437
+ @abstractmethod
438
+ def getBaseClasses(self) -> Tuple[Type, ...]:
439
+ """
440
+ Get the base classes of the instance's class.
441
+
442
+ Returns
443
+ -------
444
+ Tuple[Type, ...]
445
+ Tuple of base classes
446
+ """
447
+ pass
448
+
449
+ @abstractmethod
450
+ def isInstanceOf(self, cls: Type) -> bool:
451
+ """
452
+ Check if the instance is of a specific class.
453
+
454
+ Parameters
455
+ ----------
456
+ cls : Type
457
+ The class to check against
458
+
459
+ Returns
460
+ -------
461
+ bool
462
+ True if the instance is of the specified class
463
+ """
464
+ pass
465
+
466
+ @abstractmethod
467
+ def getSourceCode(self) -> Optional[str]:
468
+ """
469
+ Get the source code of the instance's class.
470
+
471
+ Returns
472
+ -------
473
+ Optional[str]
474
+ The source code if available, None otherwise
475
+ """
476
+ pass
477
+
478
+ @abstractmethod
479
+ def getFileLocation(self) -> Optional[str]:
480
+ """
481
+ Get the file location where the class is defined.
482
+
483
+ Returns
484
+ -------
485
+ Optional[str]
486
+ The file path if available, None otherwise
487
+ """
488
+ pass
489
+
490
+ @abstractmethod
491
+ def getAnnotations(self) -> Dict[str, Any]:
492
+ """
493
+ Get type annotations of the class.
494
+
495
+ Returns
496
+ -------
497
+ Dict[str, Any]
498
+ Dictionary of attribute names and their type annotations
499
+ """
500
+ pass
501
+
502
+ @abstractmethod
503
+ def hasAttribute(self, name: str) -> bool:
504
+ """
505
+ Check if the instance has a specific attribute.
506
+
507
+ Parameters
508
+ ----------
509
+ name : str
510
+ The attribute name to check
511
+
512
+ Returns
513
+ -------
514
+ bool
515
+ True if the attribute exists
516
+ """
517
+ pass
518
+
519
+ @abstractmethod
520
+ def getAttribute(self, name: str) -> Any:
521
+ """
522
+ Get an attribute value by name.
523
+
524
+ Parameters
525
+ ----------
526
+ name : str
527
+ The attribute name
528
+
529
+ Returns
530
+ -------
531
+ Any
532
+ The attribute value
533
+
534
+ Raises
535
+ ------
536
+ AttributeError
537
+ If the attribute doesn't exist
538
+ """
539
+ pass
540
+
541
+ @abstractmethod
542
+ def setAttribute(self, name: str, value: Any) -> None:
543
+ """
544
+ Set an attribute value.
545
+
546
+ Parameters
547
+ ----------
548
+ name : str
549
+ The attribute name
550
+ value : Any
551
+ The value to set
552
+
553
+ Raises
554
+ ------
555
+ AttributeError
556
+ If the attribute is read-only
557
+ """
558
+ pass
559
+
560
+ @abstractmethod
561
+ def removeAttribute(self, name: str) -> None:
562
+ """
563
+ Remove an attribute from the instance.
564
+
565
+ Parameters
566
+ ----------
567
+ name : str
568
+ The attribute name to remove
569
+
570
+ Raises
571
+ ------
572
+ AttributeError
573
+ If the attribute doesn't exist or is read-only
574
+ """
575
+ pass
576
+
577
+ @abstractmethod
578
+ def setMacro(self, name: str, value: Callable) -> None:
579
+ """
580
+ Set a callable attribute value.
581
+
582
+ Parameters
583
+ ----------
584
+ name : str
585
+ The attribute name
586
+ value : Callable
587
+ The callable to set
588
+
589
+ Raises
590
+ ------
591
+ AttributeError
592
+ If the value is not callable
593
+ """
594
+ pass
595
+
596
+ @abstractmethod
597
+ def removeMacro(self, name: str) -> None:
598
+ """
599
+ Remove a callable attribute from the instance.
600
+
601
+ Parameters
602
+ ----------
603
+ name : str
604
+ The attribute name to remove
605
+
606
+ Raises
607
+ ------
608
+ AttributeError
609
+ If the attribute doesn't exist or is not callable
610
+ """
611
+ pass
612
+
613
+ @abstractmethod
614
+ def getConstructorDependencies(self):
615
+ """
616
+ Get the resolved and unresolved dependencies from the constructor of the instance's class.
617
+
618
+ Returns
619
+ -------
620
+ ClassDependency
621
+ A structured representation of the constructor dependencies, containing:
622
+ - resolved: Dictionary of resolved dependencies with their names and values.
623
+ - unresolved: List of unresolved dependencies (parameter names without default values or annotations).
624
+ """
625
+ pass
626
+
627
+ @abstractmethod
628
+ def getMethodDependencies(self, method_name: str):
629
+ """
630
+ Get the resolved and unresolved dependencies from a method of the instance's class.
631
+
632
+ Parameters
633
+ ----------
634
+ method_name : str
635
+ The name of the method to inspect
636
+
637
+ Returns
638
+ -------
639
+ MethodDependency
640
+ A structured representation of the method dependencies, containing:
641
+ - resolved: Dictionary of resolved dependencies with their names and values.
642
+ - unresolved: List of unresolved dependencies (parameter names without default values or annotations).
643
+ """
644
+ pass
@@ -4,12 +4,13 @@ from orionis.luminate.support.asynchrony.async_io import AsyncIO
4
4
  from orionis.luminate.support.introspection.dependencies import ReflectDependencies
5
5
  from orionis.luminate.support.introspection.dependencies.entities.class_dependencies import ClassDependency
6
6
  from orionis.luminate.support.introspection.dependencies.entities.method_dependencies import MethodDependency
7
+ from orionis.luminate.support.introspection.instances.contracts.reflection_instance import IReflectionInstance
7
8
  from orionis.luminate.support.introspection.instances.entities.class_attributes import ClassAttributes
8
9
  from orionis.luminate.support.introspection.instances.entities.class_method import ClassMethod
9
10
  from orionis.luminate.support.introspection.instances.entities.class_parsed import ClassParsed
10
11
  from orionis.luminate.support.introspection.instances.entities.class_property import ClassProperty
11
12
 
12
- class ReflectionInstance:
13
+ class ReflectionInstance(IReflectionInstance):
13
14
  """
14
15
  A reflection object encapsulating a class instance.
15
16
 
@@ -104,6 +105,8 @@ class ReflectionInstance:
104
105
  protected = {}
105
106
 
106
107
  for attr, value in attributes.items():
108
+ if (str(attr).startswith("__") and str(attr).endswith("__")):
109
+ continue
107
110
  if str(attr).startswith("_") and not str(attr).startswith("__") and not str(attr).startswith(f"_{class_name}"):
108
111
  protected[attr] = value
109
112
  elif str(attr).startswith(f"_{class_name}"):
@@ -2,7 +2,7 @@ import abc
2
2
  from typing import Any, Type, TypeVar
3
3
  from orionis.luminate.contracts.support.reflection import IReflection
4
4
  from orionis.luminate.support.introspection.helpers.functions import HelpersReflection
5
- from orionis.luminate.support.introspection.reflect_abstract import ReflexionAbstract
5
+ from orionis.luminate.support.introspection.abstracts.reflect_abstract import ReflexionAbstract
6
6
  from orionis.luminate.support.introspection.reflexion_concrete import ReflexionConcrete
7
7
  from orionis.luminate.support.introspection.reflexion_concrete_with_abstract import ReflexionConcreteWithAbstract
8
8
  from orionis.luminate.support.introspection.instances.reflection_instance import ReflectionInstance
@@ -1,7 +1,7 @@
1
1
  import abc
2
2
  import inspect
3
3
  from typing import Any, Dict, List, Tuple, Type, TypeVar, Union
4
- from orionis.luminate.support.introspection.reflect_abstract import ReflexionAbstract
4
+ from orionis.luminate.support.introspection.abstracts.reflect_abstract import ReflexionAbstract
5
5
  from orionis.luminate.support.introspection.reflexion_concrete import ReflexionConcrete
6
6
 
7
7
  T = TypeVar('T')
@@ -1,7 +1,7 @@
1
1
  import abc
2
2
  import inspect
3
3
  from typing import Any, Dict, List, Tuple, Type, TypeVar, Union
4
- from orionis.luminate.support.introspection.reflect_abstract import ReflexionAbstract
4
+ from orionis.luminate.support.introspection.abstracts.reflect_abstract import ReflexionAbstract
5
5
  from orionis.luminate.support.introspection.instances.reflection_instance import ReflectionInstance
6
6
 
7
7
  T = TypeVar('T')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.239.0
3
+ Version: 0.240.0
4
4
  Summary: Orionis Framework – Elegant, Fast, and Powerful.
5
5
  Home-page: https://github.com/orionis-framework/framework
6
6
  Author: Raul Mauricio Uñate Castro