orionis 0.298.0__py3-none-any.whl → 0.300.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.
@@ -0,0 +1,869 @@
1
+ from abc import ABC, abstractmethod
2
+ import inspect
3
+ from typing import Any, Callable, Dict, List, Optional, Tuple, Type
4
+ from orionis.services.introspection.dependencies.entities.class_dependencies import ClassDependency
5
+ from orionis.services.introspection.dependencies.entities.method_dependencies import MethodDependency
6
+
7
+ class IReflectionInstance(ABC):
8
+
9
+ @abstractmethod
10
+ def getClass(self) -> Type:
11
+ """
12
+ Get the class of the instance.
13
+
14
+ Returns
15
+ -------
16
+ Type
17
+ The class object of the instance
18
+ """
19
+ pass
20
+
21
+ @abstractmethod
22
+ def getInstance(self) -> Any:
23
+ """
24
+ Get the instance being reflected upon.
25
+
26
+ Returns
27
+ -------
28
+ Any
29
+ The object instance
30
+ """
31
+ pass
32
+
33
+ @abstractmethod
34
+ def getClassName(self) -> str:
35
+ """
36
+ Get the name of the instance's class.
37
+
38
+ Returns
39
+ -------
40
+ str
41
+ The name of the class
42
+ """
43
+ pass
44
+
45
+ @abstractmethod
46
+ def getModuleName(self) -> str:
47
+ """
48
+ Get the name of the module where the class is defined.
49
+
50
+ Returns
51
+ -------
52
+ str
53
+ The module name
54
+ """
55
+ pass
56
+
57
+ @abstractmethod
58
+ def getModuleWithClassName(self) -> str:
59
+ """
60
+ Get the name of the module where the class is defined.
61
+
62
+ Returns
63
+ -------
64
+ str
65
+ The module name
66
+ """
67
+ pass
68
+
69
+ @abstractmethod
70
+ def getDocstring(self) -> Optional[str]:
71
+ """
72
+ Get the docstring of the instance's class.
73
+
74
+ Returns
75
+ -------
76
+ Optional[str]
77
+ The class docstring, or None if not available
78
+ """
79
+ pass
80
+
81
+ @abstractmethod
82
+ def getBaseClasses(self) -> Tuple[Type, ...]:
83
+ """
84
+ Get the base classes of the instance's class.
85
+
86
+ Returns
87
+ -------
88
+ Tuple[Type, ...]
89
+ Tuple of base classes
90
+ """
91
+ pass
92
+
93
+ @abstractmethod
94
+ def getSourceCode(self) -> Optional[str]:
95
+ """
96
+ Get the source code of the instance's class.
97
+
98
+ Returns
99
+ -------
100
+ Optional[str]
101
+ The source code if available, None otherwise
102
+ """
103
+ pass
104
+
105
+ @abstractmethod
106
+ def getFile(self) -> Optional[str]:
107
+ """
108
+ Get the file location where the class is defined.
109
+
110
+ Returns
111
+ -------
112
+ Optional[str]
113
+ The file path if available, None otherwise
114
+ """
115
+ pass
116
+
117
+ @abstractmethod
118
+ def getAnnotations(self) -> Dict[str, Any]:
119
+ """
120
+ Get type annotations of the class.
121
+
122
+ Returns
123
+ -------
124
+ Dict[str, Any]
125
+ Dictionary of attribute names and their type annotations
126
+ """
127
+ pass
128
+
129
+ @abstractmethod
130
+ def hasAttribute(self, name: str) -> bool:
131
+ """
132
+ Check if the instance has a specific attribute.
133
+
134
+ Parameters
135
+ ----------
136
+ name : str
137
+ The attribute name to check
138
+
139
+ Returns
140
+ -------
141
+ bool
142
+ True if the attribute exists
143
+ """
144
+ pass
145
+
146
+ @abstractmethod
147
+ def getAttribute(self, name: str) -> Any:
148
+ """
149
+ Get an attribute value by name.
150
+
151
+ Parameters
152
+ ----------
153
+ name : str
154
+ The attribute name
155
+
156
+ Returns
157
+ -------
158
+ Any
159
+ The attribute value
160
+
161
+ Raises
162
+ ------
163
+ AttributeError
164
+ If the attribute doesn't exist
165
+ """
166
+ pass
167
+
168
+ @abstractmethod
169
+ def setAttribute(self, name: str, value: Any) -> bool:
170
+ """
171
+ Set an attribute value.
172
+
173
+ Parameters
174
+ ----------
175
+ name : str
176
+ The attribute name
177
+ value : Any
178
+ The value to set
179
+
180
+ Raises
181
+ ------
182
+ ReflectionAttributeError
183
+ If the attribute is read-only
184
+ """
185
+ pass
186
+
187
+ @abstractmethod
188
+ def removeAttribute(self, name: str) -> bool:
189
+ """
190
+ Remove an attribute from the instance.
191
+
192
+ Parameters
193
+ ----------
194
+ name : str
195
+ The attribute name to remove
196
+
197
+ Raises
198
+ ------
199
+ ReflectionAttributeError
200
+ If the attribute doesn't exist or is read-only
201
+ """
202
+ pass
203
+
204
+ @abstractmethod
205
+ def getAttributes(self) -> Dict[str, Any]:
206
+ """
207
+ Get all attributes of the instance, including public, private, protected, and dunder attributes.
208
+
209
+ Returns
210
+ -------
211
+ Dict[str, Any]
212
+ Dictionary of all attribute names and their values
213
+ """
214
+ pass
215
+
216
+ @abstractmethod
217
+ def getPublicAttributes(self) -> Dict[str, Any]:
218
+ """
219
+ Get all public attributes of the instance.
220
+
221
+ Returns
222
+ -------
223
+ Dict[str, Any]
224
+ Dictionary of public attribute names and their values
225
+ """
226
+ pass
227
+
228
+ @abstractmethod
229
+ def getProtectedAttributes(self) -> Dict[str, Any]:
230
+ """
231
+ Get all Protected attributes of the instance.
232
+
233
+ Returns
234
+ -------
235
+ Dict[str, Any]
236
+ Dictionary of Protected attribute names and their values
237
+ """
238
+ pass
239
+
240
+ @abstractmethod
241
+ def getPrivateAttributes(self) -> Dict[str, Any]:
242
+ """
243
+ Get all private attributes of the instance.
244
+
245
+ Returns
246
+ -------
247
+ Dict[str, Any]
248
+ Dictionary of private attribute names and their values
249
+ """
250
+ pass
251
+
252
+ @abstractmethod
253
+ def getDunderAttributes(self) -> Dict[str, Any]:
254
+ """
255
+ Get all dunder (double underscore) attributes of the instance.
256
+
257
+ Returns
258
+ -------
259
+ Dict[str, Any]
260
+ Dictionary of dunder attribute names and their values
261
+ """
262
+ pass
263
+
264
+ @abstractmethod
265
+ def getMagicAttributes(self) -> Dict[str, Any]:
266
+ """
267
+ Get all magic attributes of the instance.
268
+
269
+ Returns
270
+ -------
271
+ Dict[str, Any]
272
+ Dictionary of magic attribute names and their values
273
+ """
274
+ pass
275
+
276
+ @abstractmethod
277
+ def hasMethod(self, name: str) -> bool:
278
+ """
279
+ Check if the instance has a specific method.
280
+
281
+ Parameters
282
+ ----------
283
+ name : str
284
+ The method name to check
285
+
286
+ Returns
287
+ -------
288
+ bool
289
+ True if the method exists, False otherwise
290
+ """
291
+ pass
292
+
293
+ @abstractmethod
294
+ def callMethod(self, name: str, *args: Any, **kwargs: Any) -> Any:
295
+ """
296
+ Call a method on the instance.
297
+
298
+ Parameters
299
+ ----------
300
+ name : str
301
+ Name of the method to call
302
+ *args : Any
303
+ Positional arguments for the method
304
+ **kwargs : Any
305
+ Keyword arguments for the method
306
+
307
+ Returns
308
+ -------
309
+ Any
310
+ The result of the method call
311
+
312
+ Raises
313
+ ------
314
+ AttributeError
315
+ If the method does not exist on the instance
316
+ TypeError
317
+ If the method is not callable
318
+ """
319
+ pass
320
+
321
+ @abstractmethod
322
+ def setMethod(self, name: str, value: Callable) -> bool:
323
+ """
324
+ Set a callable attribute value.
325
+
326
+ Parameters
327
+ ----------
328
+ name : str
329
+ The attribute name
330
+ value : Callable
331
+ The callable to set
332
+
333
+ Raises
334
+ ------
335
+ ReflectionAttributeError
336
+ If the attribute is not callable or already exists as a method
337
+ """
338
+ pass
339
+
340
+ @abstractmethod
341
+ def removeMethod(self, name: str) -> None:
342
+ """
343
+ Remove a method from the instance.
344
+
345
+ Parameters
346
+ ----------
347
+ name : str
348
+ The method name to remove
349
+
350
+ Raises
351
+ ------
352
+ ReflectionAttributeError
353
+ If the method does not exist or is not callable
354
+ """
355
+ pass
356
+
357
+ @abstractmethod
358
+ def getMethodSignature(self, name: str) -> inspect.Signature:
359
+ """
360
+ Get the signature of a method.
361
+
362
+ Parameters
363
+ ----------
364
+ name : str
365
+ Name of the method
366
+
367
+ Returns
368
+ -------
369
+ inspect.Signature
370
+ The method signature
371
+ """
372
+ pass
373
+
374
+ @abstractmethod
375
+ def getMethods(self) -> List[str]:
376
+ """
377
+ Get all method names of the instance.
378
+
379
+ Returns
380
+ -------
381
+ List[str]
382
+ List of method names
383
+ """
384
+ pass
385
+
386
+ @abstractmethod
387
+ def getPublicMethods(self) -> List[str]:
388
+ """
389
+ Get all public method names of the instance.
390
+
391
+ Returns
392
+ -------
393
+ List[str]
394
+ List of public method names
395
+ """
396
+ pass
397
+
398
+ @abstractmethod
399
+ def getPublicSyncMethods(self) -> List[str]:
400
+ """
401
+ Get all public synchronous method names of the instance.
402
+
403
+ Returns
404
+ -------
405
+ List[str]
406
+ List of public synchronous method names
407
+ """
408
+ pass
409
+
410
+ @abstractmethod
411
+ def getPublicAsyncMethods(self) -> List[str]:
412
+ """
413
+ Get all public asynchronous method names of the instance.
414
+
415
+ Returns
416
+ -------
417
+ List[str]
418
+ List of public asynchronous method names
419
+ """
420
+ pass
421
+
422
+ @abstractmethod
423
+ def getProtectedMethods(self) -> List[str]:
424
+ """
425
+ Get all protected method names of the instance.
426
+
427
+ Returns
428
+ -------
429
+ List[str]
430
+ List of protected method names
431
+ """
432
+ pass
433
+
434
+ @abstractmethod
435
+ def getProtectedSyncMethods(self) -> List[str]:
436
+ """
437
+ Get all protected synchronous method names of the instance.
438
+
439
+ Returns
440
+ -------
441
+ List[str]
442
+ List of protected synchronous method names
443
+ """
444
+ pass
445
+
446
+ @abstractmethod
447
+ def getProtectedAsyncMethods(self) -> List[str]:
448
+ """
449
+ Get all protected asynchronous method names of the instance.
450
+
451
+ Returns
452
+ -------
453
+ List[str]
454
+ List of protected asynchronous method names
455
+ """
456
+ pass
457
+
458
+ @abstractmethod
459
+ def getPrivateMethods(self) -> List[str]:
460
+ """
461
+ Get all private method names of the instance.
462
+
463
+ Returns
464
+ -------
465
+ List[str]
466
+ List of private method names
467
+ """
468
+ pass
469
+
470
+ @abstractmethod
471
+ def getPrivateSyncMethods(self) -> List[str]:
472
+ """
473
+ Get all private synchronous method names of the instance.
474
+
475
+ Returns
476
+ -------
477
+ List[str]
478
+ List of private synchronous method names
479
+ """
480
+ pass
481
+
482
+ @abstractmethod
483
+ def getPrivateAsyncMethods(self) -> List[str]:
484
+ """
485
+ Get all private asynchronous method names of the instance.
486
+
487
+ Returns
488
+ -------
489
+ List[str]
490
+ List of private asynchronous method names
491
+ """
492
+ pass
493
+
494
+ @abstractmethod
495
+ def getPublicClassMethods(self) -> List[str]:
496
+ """
497
+ Get all class method names of the instance.
498
+
499
+ Returns
500
+ -------
501
+ List[str]
502
+ List of class method names
503
+ """
504
+ pass
505
+
506
+ @abstractmethod
507
+ def getPublicClassSyncMethods(self) -> List[str]:
508
+ """
509
+ Get all public synchronous class method names of the instance.
510
+
511
+ Returns
512
+ -------
513
+ List[str]
514
+ List of public synchronous class method names
515
+ """
516
+ pass
517
+
518
+ @abstractmethod
519
+ def getPublicClassAsyncMethods(self) -> List[str]:
520
+ """
521
+ Get all public asynchronous class method names of the instance.
522
+
523
+ Returns
524
+ -------
525
+ List[str]
526
+ List of public asynchronous class method names
527
+ """
528
+ pass
529
+
530
+ @abstractmethod
531
+ def getProtectedClassMethods(self) -> List[str]:
532
+ """
533
+ Get all protected class method names of the instance.
534
+
535
+ Returns
536
+ -------
537
+ List[str]
538
+ List of protected class method names
539
+ """
540
+ pass
541
+
542
+ @abstractmethod
543
+ def getProtectedClassSyncMethods(self) -> List[str]:
544
+ """
545
+ Get all protected synchronous class method names of the instance.
546
+
547
+ Returns
548
+ -------
549
+ List[str]
550
+ List of protected synchronous class method names
551
+ """
552
+ pass
553
+
554
+ @abstractmethod
555
+ def getProtectedClassAsyncMethods(self) -> List[str]:
556
+ """
557
+ Get all protected asynchronous class method names of the instance.
558
+
559
+ Returns
560
+ -------
561
+ List[str]
562
+ List of protected asynchronous class method names
563
+ """
564
+ pass
565
+
566
+ @abstractmethod
567
+ def getPrivateClassMethods(self) -> List[str]:
568
+ """
569
+ Get all private class method names of the instance.
570
+
571
+ Returns
572
+ -------
573
+ List[str]
574
+ List of private class method names
575
+ """
576
+ pass
577
+
578
+ @abstractmethod
579
+ def getPrivateClassSyncMethods(self) -> List[str]:
580
+ """
581
+ Get all private synchronous class method names of the instance.
582
+
583
+ Returns
584
+ -------
585
+ List[str]
586
+ List of private synchronous class method names
587
+ """
588
+ pass
589
+
590
+ @abstractmethod
591
+ def getPrivateClassAsyncMethods(self) -> List[str]:
592
+ """
593
+ Get all private asynchronous class method names of the instance.
594
+
595
+ Returns
596
+ -------
597
+ List[str]
598
+ List of private asynchronous class method names
599
+ """
600
+ pass
601
+
602
+ @abstractmethod
603
+ def getPublicStaticMethods(self) -> List[str]:
604
+ """
605
+ Get public static method names of the instance.
606
+
607
+ Returns
608
+ -------
609
+ List[str]
610
+ List of static method names
611
+ """
612
+ pass
613
+
614
+ @abstractmethod
615
+ def getPublicStaticSyncMethods(self) -> List[str]:
616
+ """
617
+ Get all public synchronous static method names of the instance.
618
+
619
+ Returns
620
+ -------
621
+ List[str]
622
+ List of public synchronous static method names
623
+ """
624
+ pass
625
+
626
+ @abstractmethod
627
+ def getPublicStaticAsyncMethods(self) -> List[str]:
628
+ """
629
+ Get all public asynchronous static method names of the instance.
630
+
631
+ Returns
632
+ -------
633
+ List[str]
634
+ List of public asynchronous static method names
635
+ """
636
+ pass
637
+
638
+ @abstractmethod
639
+ def getProtectedStaticMethods(self) -> List[str]:
640
+ """
641
+ Get all protected static method names of the instance.
642
+
643
+ Returns
644
+ -------
645
+ List[str]
646
+ List of protected static method names
647
+ """
648
+ pass
649
+
650
+ @abstractmethod
651
+ def getProtectedStaticSyncMethods(self) -> List[str]:
652
+ """
653
+ Get all protected synchronous static method names of the instance.
654
+
655
+ Returns
656
+ -------
657
+ List[str]
658
+ List of protected synchronous static method names
659
+ """
660
+ pass
661
+
662
+ @abstractmethod
663
+ def getProtectedStaticAsyncMethods(self) -> List[str]:
664
+ """
665
+ Get all protected asynchronous static method names of the instance.
666
+
667
+ Returns
668
+ -------
669
+ List[str]
670
+ List of protected asynchronous static method names
671
+ """
672
+ pass
673
+
674
+ @abstractmethod
675
+ def getPrivateStaticMethods(self) -> List[str]:
676
+ """
677
+ Get all private static method names of the instance.
678
+
679
+ Returns
680
+ -------
681
+ List[str]
682
+ List of private static method names
683
+ """
684
+ pass
685
+
686
+ @abstractmethod
687
+ def getPrivateStaticSyncMethods(self) -> List[str]:
688
+ """
689
+ Get all private synchronous static method names of the instance.
690
+
691
+ Returns
692
+ -------
693
+ List[str]
694
+ List of private synchronous static method names
695
+ """
696
+ pass
697
+
698
+ @abstractmethod
699
+ def getPrivateStaticAsyncMethods(self) -> List[str]:
700
+ """
701
+ Get all private asynchronous static method names of the instance.
702
+
703
+ Returns
704
+ -------
705
+ List[str]
706
+ List of private asynchronous static method names
707
+ """
708
+ pass
709
+
710
+ @abstractmethod
711
+ def getDunderMethods(self) -> List[str]:
712
+ """
713
+ Get all dunder (double underscore) method names of the instance.
714
+
715
+ Returns
716
+ -------
717
+ List[str]
718
+ List of dunder method names
719
+ """
720
+ pass
721
+
722
+ @abstractmethod
723
+ def getMagicMethods(self) -> List[str]:
724
+ """
725
+ Get all magic method names of the instance.
726
+
727
+ Returns
728
+ -------
729
+ List[str]
730
+ List of magic method names
731
+ """
732
+ pass
733
+
734
+ @abstractmethod
735
+ def getProperties(self) -> Dict:
736
+ """
737
+ Get all properties of the instance.
738
+
739
+ Returns
740
+ -------
741
+ List[str]
742
+ List of property names
743
+ """
744
+ pass
745
+
746
+ @abstractmethod
747
+ def getPublicProperties(self) -> Dict:
748
+ """
749
+ Get all public properties of the instance.
750
+
751
+ Returns
752
+ -------
753
+ Dict
754
+ Dictionary of public property names and their values
755
+ """
756
+ pass
757
+
758
+ @abstractmethod
759
+ def getProtectedProperties(self) -> Dict:
760
+ """
761
+ Get all protected properties of the instance.
762
+
763
+ Returns
764
+ -------
765
+ Dict
766
+ Dictionary of protected property names and their values
767
+ """
768
+ pass
769
+
770
+ @abstractmethod
771
+ def getPrivateProperties(self) -> Dict:
772
+ """
773
+ Get all private properties of the instance.
774
+
775
+ Returns
776
+ -------
777
+ Dict
778
+ Dictionary of private property names and their values
779
+ """
780
+ pass
781
+
782
+ @abstractmethod
783
+ def getPropierty(self, name: str) -> Any:
784
+ """
785
+ Get a specific property of the instance.
786
+
787
+ Parameters
788
+ ----------
789
+ name : str
790
+ The name of the property to retrieve
791
+
792
+ Returns
793
+ -------
794
+ ClassProperty
795
+ The value of the specified property
796
+
797
+ Raises
798
+ ------
799
+ ReflectionAttributeError
800
+ If the property does not exist or is not accessible
801
+ """
802
+ pass
803
+
804
+ @abstractmethod
805
+ def getPropertySignature(self, name: str) -> inspect.Signature:
806
+ """
807
+ Get the signature of a property.
808
+
809
+ Parameters
810
+ ----------
811
+ name : str
812
+ Name of the property
813
+
814
+ Returns
815
+ -------
816
+ inspect.Signature
817
+ The property signature
818
+ """
819
+ pass
820
+
821
+ @abstractmethod
822
+ def getPropiertyDocstring(self, name: str) -> str:
823
+ """
824
+ Get the docstring of a property.
825
+
826
+ Parameters
827
+ ----------
828
+ name : str
829
+ Name of the property
830
+
831
+ Returns
832
+ -------
833
+ str
834
+ The docstring of the property
835
+ """
836
+ pass
837
+
838
+ @abstractmethod
839
+ def getConstructorDependencies(self) -> ClassDependency:
840
+ """
841
+ Get the resolved and unresolved dependencies from the constructor of the instance's class.
842
+
843
+ Returns
844
+ -------
845
+ ClassDependency
846
+ A structured representation of the constructor dependencies, containing:
847
+ - resolved: Dictionary of resolved dependencies with their names and values.
848
+ - unresolved: List of unresolved dependencies (parameter names without default values or annotations).
849
+ """
850
+ pass
851
+
852
+ @abstractmethod
853
+ def getMethodDependencies(self, method_name: str) -> MethodDependency:
854
+ """
855
+ Get the resolved and unresolved dependencies from a method of the instance's class.
856
+
857
+ Parameters
858
+ ----------
859
+ method_name : str
860
+ The name of the method to inspect
861
+
862
+ Returns
863
+ -------
864
+ MethodDependency
865
+ A structured representation of the method dependencies, containing:
866
+ - resolved: Dictionary of resolved dependencies with their names and values.
867
+ - unresolved: List of unresolved dependencies (parameter names without default values or annotations).
868
+ """
869
+ pass