orionis 0.304.0__py3-none-any.whl → 0.306.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 (66) hide show
  1. orionis/metadata/framework.py +1 -1
  2. orionis/services/introspection/modules/{reflection_instance.py → reflection_module.py} +1 -1
  3. orionis/services/introspection/reflection.py +90 -0
  4. orionis/{services → support}/standard/std.py +2 -2
  5. orionis/test/{facade/test_suite.py → test_suite.py} +1 -2
  6. orionis/unittesting.py +1 -1
  7. {orionis-0.304.0.dist-info → orionis-0.306.0.dist-info}/METADATA +1 -1
  8. {orionis-0.304.0.dist-info → orionis-0.306.0.dist-info}/RECORD +28 -65
  9. tests/{services → support}/standard/test_services_std.py +3 -3
  10. tests/{services → support}/wrapper/test_services_wrapper_docdict.py +2 -2
  11. orionis/support/abstracts/entities/abstract_class_attributes.py +0 -37
  12. orionis/support/abstracts/reflect_abstract.py +0 -556
  13. orionis/support/helpers/functions.py +0 -285
  14. orionis/support/introspection/container_integrity.py +0 -292
  15. orionis/support/introspection/contracts/__init__.py +0 -0
  16. orionis/support/introspection/contracts/reflection.py +0 -187
  17. orionis/support/introspection/contracts/reflexion_abstract.py +0 -264
  18. orionis/support/introspection/helpers/__init__.py +0 -0
  19. orionis/support/introspection/helpers/functions.py +0 -281
  20. orionis/support/introspection/instances/__init__.py +0 -0
  21. orionis/support/introspection/instances/contracts/__init__.py +0 -0
  22. orionis/support/introspection/instances/contracts/reflection_instance.py +0 -649
  23. orionis/support/introspection/instances/entities/__init__.py +0 -0
  24. orionis/support/introspection/instances/reflection_instance.py +0 -758
  25. orionis/support/introspection/reflect_decorators.py +0 -335
  26. orionis/support/introspection/reflection.py +0 -216
  27. orionis/support/introspection/reflexion_concrete.py +0 -276
  28. orionis/support/introspection/reflexion_concrete_with_abstract.py +0 -185
  29. orionis/support/introspection/reflexion_instance_with_abstract.py +0 -230
  30. orionis/support/introspection/reflexion_module.py +0 -19
  31. orionis/support/introspection/reflexion_module_with_classname.py +0 -22
  32. orionis/support/reflection.py +0 -216
  33. orionis/test/facade/__init__.py +0 -0
  34. orionis/test/facade/contracts/__init__.py +0 -0
  35. orionis/test/facade/contracts/test_suite.py +0 -25
  36. tests/services/standard/__init__.py +0 -0
  37. tests/services/wrapper/__init__.py +0 -0
  38. tests/support/inspection/__init__.py +0 -0
  39. tests/support/inspection/fakes/__init__.py +0 -0
  40. tests/support/inspection/fakes/fake_reflect_abstract.py +0 -276
  41. tests/support/inspection/fakes/fake_reflection_concrete.py +0 -44
  42. tests/support/inspection/fakes/fake_reflection_concrete_with_abstract.py +0 -78
  43. tests/support/inspection/fakes/fake_reflection_instance_with_abstract.py +0 -45
  44. tests/support/inspection/test_reflect_abstract.py +0 -334
  45. tests/support/inspection/test_reflect_instance.py +0 -288
  46. tests/support/inspection/test_reflection_concrete.py +0 -142
  47. tests/support/inspection/test_reflection_concrete_with_abstract.py +0 -87
  48. tests/support/inspection/test_reflection_instance_with_abstract.py +0 -79
  49. /orionis/services/introspection/modules/contracts/{reflection_instance.py → reflection_module.py} +0 -0
  50. /orionis/{services → support}/standard/__init__.py +0 -0
  51. /orionis/{services → support}/standard/contracts/__init__.py +0 -0
  52. /orionis/{services → support}/standard/contracts/std.py +0 -0
  53. /orionis/{services → support}/standard/exceptions/__init__.py +0 -0
  54. /orionis/{services → support}/standard/exceptions/std_value_exception.py +0 -0
  55. /orionis/{services → support}/wrapper/__init__.py +0 -0
  56. /orionis/{services → support}/wrapper/dicts/__init__.py +0 -0
  57. /orionis/{services → support}/wrapper/dicts/dot_dict.py +0 -0
  58. {orionis-0.304.0.dist-info → orionis-0.306.0.dist-info}/WHEEL +0 -0
  59. {orionis-0.304.0.dist-info → orionis-0.306.0.dist-info}/licenses/LICENCE +0 -0
  60. {orionis-0.304.0.dist-info → orionis-0.306.0.dist-info}/top_level.txt +0 -0
  61. {orionis-0.304.0.dist-info → orionis-0.306.0.dist-info}/zip-safe +0 -0
  62. {orionis/support/abstracts → tests/services/inspection/reflection}/__init__.py +0 -0
  63. {orionis/support/abstracts/entities → tests/services/inspection/reflection/mock}/__init__.py +0 -0
  64. /tests/{support/inspection/fakes → services/inspection/reflection/mock}/fake_reflect_instance.py +0 -0
  65. {orionis/support/helpers → tests/support/standard}/__init__.py +0 -0
  66. {orionis/support/introspection → tests/support/wrapper}/__init__.py +0 -0
@@ -1,758 +0,0 @@
1
- import inspect
2
- from typing import Any, Callable, Dict, List, Optional, Tuple, Type
3
- from orionis.support.asynchrony.async_io import AsyncIO
4
- from orionis.support.introspection.dependencies import ReflectDependencies
5
- from orionis.support.introspection.dependencies.entities.class_dependencies import ClassDependency
6
- from orionis.support.introspection.dependencies.entities.method_dependencies import MethodDependency
7
- from orionis.support.introspection.instances.contracts.reflection_instance import IReflectionInstance
8
- from orionis.support.introspection.instances.entities.class_attributes import ClassAttributes
9
- from orionis.support.introspection.instances.entities.class_method import ClassMethod
10
- from orionis.services.introspection.instances.entities.class_parsed import ClassParsed
11
- from orionis.support.introspection.instances.entities.class_property import ClassProperty
12
-
13
- class ReflectionInstance(IReflectionInstance):
14
- """
15
- A reflection object encapsulating a class instance.
16
-
17
- Parameters
18
- ----------
19
- instance : Any
20
- The instance being reflected upon
21
-
22
- Attributes
23
- ----------
24
- _instance : Any
25
- The encapsulated instance
26
- """
27
-
28
- def __init__(self, instance: Any) -> None:
29
- """Initialize with the instance to reflect upon."""
30
- self._instance = instance
31
-
32
- def parse(self) -> ClassParsed:
33
- """
34
- Parse the instance into a structured representation.
35
-
36
- This method extracts and organizes various details about the instance,
37
- including its class name, module, attributes, methods, and properties,
38
- into a `ClassParsed` object.
39
-
40
- Returns
41
- -------
42
- ClassParsed
43
- A structured representation of the instance, containing:
44
- - name: The name of the instance's class.
45
- - module: The module where the class is defined.
46
- - attributes: Categorized attributes (public, private, protected).
47
- - methods: Categorized methods (public, private, protected, static, etc.).
48
- - properties: A dictionary of properties with their details.
49
- """
50
- return ClassParsed(
51
- name=self.getClassName(),
52
- module=self.getModuleName(),
53
- attributes=self.getAllAttributes(),
54
- methods=self.getAllMethods(),
55
- properties=list(self.getAllProperties().values()),
56
- dependencies=self.getConstructorDependencies()
57
- )
58
-
59
- def getClassName(self) -> str:
60
- """
61
- Get the name of the instance's class.
62
-
63
- Returns
64
- -------
65
- str
66
- The name of the class
67
- """
68
- return self._instance.__class__.__name__
69
-
70
- def getClass(self) -> Type:
71
- """
72
- Get the class of the instance.
73
-
74
- Returns
75
- -------
76
- Type
77
- The class object of the instance
78
- """
79
- return self._instance.__class__
80
-
81
- def getModuleName(self) -> str:
82
- """
83
- Get the name of the module where the class is defined.
84
-
85
- Returns
86
- -------
87
- str
88
- The module name
89
- """
90
- return self._instance.__class__.__module__
91
-
92
- def getAllAttributes(self) -> ClassAttributes:
93
- """
94
- Get all attributes of the instance.
95
-
96
- Returns
97
- -------
98
- Dict[str, Any]
99
- Dictionary of attribute names and their values
100
- """
101
- attributes: dict = vars(self._instance)
102
- class_name: str = self.getClassName()
103
- public = {}
104
- private = {}
105
- protected = {}
106
-
107
- for attr, value in attributes.items():
108
- if (str(attr).startswith("__") and str(attr).endswith("__")):
109
- continue
110
- if str(attr).startswith("_") and not str(attr).startswith("__") and not str(attr).startswith(f"_{class_name}"):
111
- protected[attr] = value
112
- elif str(attr).startswith(f"_{class_name}"):
113
- private[str(attr).replace(f"_{class_name}", "")] = value
114
- else:
115
- public[attr] = value
116
-
117
- return ClassAttributes(
118
- public=public,
119
- private=private,
120
- protected=protected
121
- )
122
-
123
- def getAttributes(self) -> Dict[str, Any]:
124
- """
125
- Get all attributes of the instance.
126
-
127
- Returns
128
- -------
129
- Dict[str, Any]
130
- Dictionary of attribute names and their values
131
- """
132
- attr = self.getAllAttributes()
133
- return {**attr.public, **attr.private, **attr.protected}
134
-
135
- def getPublicAttributes(self) -> Dict[str, Any]:
136
- """
137
- Get all public attributes of the instance.
138
-
139
- Returns
140
- -------
141
- Dict[str, Any]
142
- Dictionary of public attribute names and their values
143
- """
144
- attr = self.getAllAttributes()
145
- return attr.public
146
-
147
- def getPrivateAttributes(self) -> Dict[str, Any]:
148
- """
149
- Get all private attributes of the instance.
150
-
151
- Returns
152
- -------
153
- Dict[str, Any]
154
- Dictionary of private attribute names and their values
155
- """
156
- attr = self.getAllAttributes()
157
- return attr.private
158
-
159
- def getProtectedAttributes(self) -> Dict[str, Any]:
160
- """
161
- Get all Protected attributes of the instance.
162
-
163
- Returns
164
- -------
165
- Dict[str, Any]
166
- Dictionary of Protected attribute names and their values
167
- """
168
- attr = self.getAllAttributes()
169
- return attr.protected
170
-
171
- def getAllMethods(self):
172
- """
173
- Retrieves and categorizes all methods of the instance's class into various classifications.
174
- This method inspects the instance's class and its methods, categorizing them into public, private,
175
- protected, static, asynchronous, synchronous, class methods, asynchronous static, synchronous static,
176
- and magic methods.
177
- Returns
178
- -------
179
- ClassMethod
180
- An object containing categorized lists of method names:
181
- - public: List of public instance methods.
182
- - private: List of private instance methods (names without the class prefix).
183
- - protected: List of protected instance methods.
184
- - static: List of static methods.
185
- - asynchronous: List of asynchronous instance methods.
186
- - synchronous: List of synchronous instance methods.
187
- - class_methods: List of class methods.
188
- - asynchronous_static: List of asynchronous static methods.
189
- - synchronous_static: List of synchronous static methods.
190
- - magic: List of magic methods (e.g., `__init__`, `__str__`).
191
- Notes
192
- -----
193
- - Magic methods are identified by their double underscore prefix and suffix (e.g., `__init__`).
194
- - Private methods are identified by a single underscore followed by the class name.
195
- - Protected methods are identified by a single underscore prefix.
196
- - Public methods are identified as methods without any leading underscores.
197
- - Static and class methods are identified using `inspect.getattr_static`.
198
- - Asynchronous methods are identified using `inspect.iscoroutinefunction`.
199
- - Synchronous methods are identified as methods that are not asynchronous, static, or class methods.
200
- """
201
- class_name = self.getClassName()
202
- cls = self._instance.__class__
203
-
204
- result = ClassMethod(
205
- public=[], private=[], protected=[], static=[],
206
- asynchronous=[], synchronous=[], class_methods=[],
207
- asynchronous_static=[], synchronous_static=[], magic=[]
208
- )
209
-
210
- # Categorize magic methods
211
- result.magic = [name for name in dir(self._instance) if name.startswith("__") and name.endswith("__")]
212
-
213
- # Classify static and class methods
214
- for name in dir(cls):
215
- attr = inspect.getattr_static(cls, name)
216
- if isinstance(attr, staticmethod):
217
- result.static.append(name)
218
- elif isinstance(attr, classmethod):
219
- result.class_methods.append(name)
220
-
221
- # Classify instance methods
222
- for name, method in inspect.getmembers(self._instance, predicate=inspect.ismethod):
223
- if name in result.class_methods or name in result.magic:
224
- continue
225
- if name.startswith(f"_{class_name}"):
226
- result.private.append(name.replace(f"_{class_name}", ""))
227
- elif name.startswith("_"):
228
- result.protected.append(name)
229
- else:
230
- result.public.append(name)
231
-
232
- # Classify asynchronous and synchronous methods
233
- for name, method in inspect.getmembers(cls, predicate=inspect.iscoroutinefunction):
234
- clean_name = name.replace(f"_{class_name}", "")
235
- if name in result.static:
236
- result.asynchronous_static.append(clean_name)
237
- else:
238
- result.asynchronous.append(clean_name)
239
-
240
- for name, method in inspect.getmembers(self._instance, predicate=inspect.ismethod):
241
- clean_name = name.replace(f"_{class_name}", "")
242
- if name not in result.static and clean_name not in result.asynchronous and name not in result.class_methods and name not in result.magic:
243
- result.synchronous.append(clean_name)
244
-
245
- # Determine synchronous static methods
246
- for name in result.static:
247
- if name not in result.asynchronous_static and name not in result.class_methods:
248
- result.synchronous_static.append(name)
249
-
250
- return result
251
-
252
- def getMethods(self) -> List[str]:
253
- """
254
- Get all method names of the instance.
255
-
256
- Returns
257
- -------
258
- List[str]
259
- List of method names
260
- """
261
- methods = self.getAllMethods()
262
- return methods.public + methods.private + methods.protected + methods.static + methods.class_methods
263
-
264
- def getProtectedMethods(self) -> List[str]:
265
- """
266
- Get all protected method names of the instance.
267
-
268
- Returns
269
- -------
270
- List[str]
271
- List of protected method names, excluding private methods (starting with '_')
272
- """
273
- methods = self.getAllMethods()
274
- return methods.protected
275
-
276
- def getPrivateMethods(self) -> List[str]:
277
- """
278
- Get all private method names of the instance.
279
-
280
- Returns
281
- -------
282
- List[str]
283
- List of private method names, excluding protected methods (starting with '_')
284
- """
285
- methods = self.getAllMethods()
286
- return methods.private
287
-
288
- def getStaticMethods(self) -> List[str]:
289
- """
290
- Get all static method names of the instance.
291
-
292
- Returns
293
- -------
294
- List[str]
295
- List of static method names.
296
- """
297
- methods = self.getAllMethods()
298
- return methods.static
299
-
300
- def getAsyncMethods(self) -> List[str]:
301
- """
302
- Get all asynchronous method names of the instance that are not static methods.
303
-
304
- Returns
305
- -------
306
- List[str]
307
- List of asynchronous method names
308
- """
309
- methods = self.getAllMethods()
310
- return methods.asynchronous
311
-
312
- def getSyncMethods(self) -> List[str]:
313
- """
314
- Get all synchronous method names of the instance that are not static methods.
315
-
316
- Returns
317
- -------
318
- List[str]
319
- List of synchronous method names
320
- """
321
- methods = self.getAllMethods()
322
- return methods.synchronous
323
-
324
- def getClassMethods(self) -> List[str]:
325
- """
326
- Get all class method names of the instance.
327
-
328
- Returns
329
- -------
330
- List[str]
331
- List of class method names.
332
- """
333
- methods = self.getAllMethods()
334
- return methods.class_methods
335
-
336
- def getAsyncStaticMethods(self) -> List[str]:
337
- """
338
- Get all asynchronous method names of the instance that are not static methods.
339
-
340
- Returns
341
- -------
342
- List[str]
343
- List of asynchronous method names
344
- """
345
- methods = self.getAllMethods()
346
- return methods.asynchronous_static
347
-
348
- def getSyncStaticMethods(self) -> List[str]:
349
- """
350
- Get all synchronous static method names of the instance.
351
-
352
- Returns
353
- -------
354
- List[str]
355
- List of synchronous static method names
356
- """
357
- methods = self.getAllMethods()
358
- return methods.synchronous_static
359
-
360
- def getMagicMethods(self) -> List[str]:
361
- """
362
- Get all magic method names of the instance.
363
-
364
- Returns
365
- -------
366
- List[str]
367
- List of magic method names
368
- """
369
- methods = self.getAllMethods()
370
- return methods.magic
371
-
372
- def getAllProperties(self) -> Dict[str, ClassProperty]:
373
- """
374
- Get all properties of the instance.
375
-
376
- Returns
377
- -------
378
- List[str]
379
- List of property names
380
- """
381
-
382
- properties = {}
383
- for name, prop in self._instance.__class__.__dict__.items():
384
- if isinstance(prop, property):
385
- properties[name] = ClassProperty(
386
- name=name,
387
- value=getattr(self._instance, name, None),
388
- signature=inspect.signature(prop.fget) if prop.fget else None,
389
- doc=prop.__doc__ or ""
390
- )
391
- return properties
392
-
393
- def getPropertyNames(self) -> List[str]:
394
- """
395
- Get all property names of the instance.
396
-
397
- Returns
398
- -------
399
- List[str]
400
- List of property names
401
- """
402
- return self.getAllProperties().keys()
403
-
404
- def getProperty(self, property_name: str) -> Any:
405
- """
406
- Get the value of a property.
407
-
408
- Parameters
409
- ----------
410
- property_name : str
411
- Name of the property
412
-
413
- Returns
414
- -------
415
- Any
416
- The value of the property
417
-
418
- Raises
419
- ------
420
- AttributeError
421
- If the property doesn't exist or is not a property
422
- """
423
- all_prop = self.getAllProperties()
424
- if property_name not in all_prop:
425
- raise ValueError(f"Property '{property_name}' not found.")
426
- return all_prop[property_name].value
427
-
428
- def getPropertySignature(self, property_name: str) -> inspect.Signature:
429
- """
430
- Get the signature of a property.
431
-
432
- Parameters
433
- ----------
434
- property_name : str
435
- Name of the property
436
-
437
- Returns
438
- -------
439
- inspect.Signature
440
- The property signature
441
-
442
- Raises
443
- ------
444
- AttributeError
445
- If the property doesn't exist or is not a property
446
- """
447
- all_prop = self.getAllProperties()
448
- if property_name not in all_prop:
449
- raise ValueError(f"Property '{property_name}' not found.")
450
- return all_prop[property_name].signature
451
-
452
- def getPropertyDoc(self, property_name: str) -> str:
453
- """
454
- Get the docstring of a property.
455
-
456
- Parameters
457
- ----------
458
- property_name : str
459
- Name of the property
460
-
461
- Returns
462
- -------
463
- str
464
- The docstring of the property
465
-
466
- Raises
467
- ------
468
- AttributeError
469
- If the property doesn't exist or is not a property
470
- """
471
- all_prop = self.getAllProperties()
472
- if property_name not in all_prop:
473
- raise ValueError(f"Property '{property_name}' not found.")
474
- return all_prop[property_name].doc
475
-
476
- def callMethod(self, method_name: str, *args: Any, **kwargs: Any) -> Any:
477
- """
478
- Call a method on the instance.
479
-
480
- Parameters
481
- ----------
482
- method_name : str
483
- Name of the method to call
484
- *args : Any
485
- Positional arguments for the method
486
- **kwargs : Any
487
- Keyword arguments for the method
488
-
489
- Returns
490
- -------
491
- Any
492
- The result of the method call
493
-
494
- Raises
495
- ------
496
- AttributeError
497
- If the method does not exist on the instance
498
- TypeError
499
- If the method is not callable
500
- """
501
-
502
- if method_name in self.getPrivateMethods():
503
- method_name = f"_{self.getClassName()}{method_name}"
504
-
505
- method = getattr(self._instance, method_name, None)
506
-
507
- if method is None:
508
- raise AttributeError(f"'{self.getClassName()}' object has no method '{method_name}'.")
509
- if not callable(method):
510
- raise TypeError(f"'{method_name}' is not callable on '{self.getClassName()}'.")
511
-
512
- if inspect.iscoroutinefunction(method):
513
- return AsyncIO.run(method(*args, **kwargs))
514
-
515
- return method(*args, **kwargs)
516
-
517
- def getMethodSignature(self, method_name: str) -> inspect.Signature:
518
- """
519
- Get the signature of a method.
520
-
521
- Parameters
522
- ----------
523
- method_name : str
524
- Name of the method
525
-
526
- Returns
527
- -------
528
- inspect.Signature
529
- The method signature
530
- """
531
- if method_name in self.getPrivateMethods():
532
- method_name = f"_{self.getClassName()}{method_name}"
533
-
534
- method = getattr(self._instance, method_name)
535
- if callable(method):
536
- return inspect.signature(method)
537
-
538
- def getDocstring(self) -> Optional[str]:
539
- """
540
- Get the docstring of the instance's class.
541
-
542
- Returns
543
- -------
544
- Optional[str]
545
- The class docstring, or None if not available
546
- """
547
- return self._instance.__class__.__doc__
548
-
549
- def getBaseClasses(self) -> Tuple[Type, ...]:
550
- """
551
- Get the base classes of the instance's class.
552
-
553
- Returns
554
- -------
555
- Tuple[Type, ...]
556
- Tuple of base classes
557
- """
558
- return self._instance.__class__.__bases__
559
-
560
- def isInstanceOf(self, cls: Type) -> bool:
561
- """
562
- Check if the instance is of a specific class.
563
-
564
- Parameters
565
- ----------
566
- cls : Type
567
- The class to check against
568
-
569
- Returns
570
- -------
571
- bool
572
- True if the instance is of the specified class
573
- """
574
- return isinstance(self._instance, cls)
575
-
576
- def getSourceCode(self) -> Optional[str]:
577
- """
578
- Get the source code of the instance's class.
579
-
580
- Returns
581
- -------
582
- Optional[str]
583
- The source code if available, None otherwise
584
- """
585
- try:
586
- return inspect.getsource(self._instance.__class__)
587
- except (TypeError, OSError):
588
- return None
589
-
590
- def getFileLocation(self) -> Optional[str]:
591
- """
592
- Get the file location where the class is defined.
593
-
594
- Returns
595
- -------
596
- Optional[str]
597
- The file path if available, None otherwise
598
- """
599
- try:
600
- return inspect.getfile(self._instance.__class__)
601
- except (TypeError, OSError):
602
- return None
603
-
604
- def getAnnotations(self) -> Dict[str, Any]:
605
- """
606
- Get type annotations of the class.
607
-
608
- Returns
609
- -------
610
- Dict[str, Any]
611
- Dictionary of attribute names and their type annotations
612
- """
613
- return self._instance.__class__.__annotations__
614
-
615
- def hasAttribute(self, name: str) -> bool:
616
- """
617
- Check if the instance has a specific attribute.
618
-
619
- Parameters
620
- ----------
621
- name : str
622
- The attribute name to check
623
-
624
- Returns
625
- -------
626
- bool
627
- True if the attribute exists
628
- """
629
- return hasattr(self._instance, name)
630
-
631
- def getAttribute(self, name: str) -> Any:
632
- """
633
- Get an attribute value by name.
634
-
635
- Parameters
636
- ----------
637
- name : str
638
- The attribute name
639
-
640
- Returns
641
- -------
642
- Any
643
- The attribute value
644
-
645
- Raises
646
- ------
647
- AttributeError
648
- If the attribute doesn't exist
649
- """
650
- attrs = self.getAttributes()
651
- return attrs.get(name, getattr(self._instance, name, None))
652
-
653
- def setAttribute(self, name: str, value: Any) -> None:
654
- """
655
- Set an attribute value.
656
-
657
- Parameters
658
- ----------
659
- name : str
660
- The attribute name
661
- value : Any
662
- The value to set
663
-
664
- Raises
665
- ------
666
- AttributeError
667
- If the attribute is read-only
668
- """
669
- if callable(value):
670
- raise AttributeError(f"Cannot set attribute '{name}' to a callable. Use setMacro instead.")
671
- setattr(self._instance, name, value)
672
-
673
- def removeAttribute(self, name: str) -> None:
674
- """
675
- Remove an attribute from the instance.
676
-
677
- Parameters
678
- ----------
679
- name : str
680
- The attribute name to remove
681
-
682
- Raises
683
- ------
684
- AttributeError
685
- If the attribute doesn't exist or is read-only
686
- """
687
- if not hasattr(self._instance, name):
688
- raise AttributeError(f"'{self.getClassName()}' object has no attribute '{name}'.")
689
- delattr(self._instance, name)
690
-
691
- def setMacro(self, name: str, value: Callable) -> None:
692
- """
693
- Set a callable attribute value.
694
-
695
- Parameters
696
- ----------
697
- name : str
698
- The attribute name
699
- value : Callable
700
- The callable to set
701
-
702
- Raises
703
- ------
704
- AttributeError
705
- If the value is not callable
706
- """
707
- if not callable(value):
708
- raise AttributeError(f"The value for '{name}' must be a callable.")
709
- setattr(self._instance, name, value)
710
-
711
- def removeMacro(self, name: str) -> None:
712
- """
713
- Remove a callable attribute from the instance.
714
-
715
- Parameters
716
- ----------
717
- name : str
718
- The attribute name to remove
719
-
720
- Raises
721
- ------
722
- AttributeError
723
- If the attribute doesn't exist or is not callable
724
- """
725
- if not hasattr(self._instance, name) or not callable(getattr(self._instance, name)):
726
- raise AttributeError(f"'{self.getClassName()}' object has no callable macro '{name}'.")
727
- delattr(self._instance, name)
728
-
729
- def getConstructorDependencies(self) -> ClassDependency:
730
- """
731
- Get the resolved and unresolved dependencies from the constructor of the instance's class.
732
-
733
- Returns
734
- -------
735
- ClassDependency
736
- A structured representation of the constructor dependencies, containing:
737
- - resolved: Dictionary of resolved dependencies with their names and values.
738
- - unresolved: List of unresolved dependencies (parameter names without default values or annotations).
739
- """
740
- return ReflectDependencies(self._instance.__class__).getConstructorDependencies()
741
-
742
- def getMethodDependencies(self, method_name: str) -> MethodDependency:
743
- """
744
- Get the resolved and unresolved dependencies from a method of the instance's class.
745
-
746
- Parameters
747
- ----------
748
- method_name : str
749
- The name of the method to inspect
750
-
751
- Returns
752
- -------
753
- MethodDependency
754
- A structured representation of the method dependencies, containing:
755
- - resolved: Dictionary of resolved dependencies with their names and values.
756
- - unresolved: List of unresolved dependencies (parameter names without default values or annotations).
757
- """
758
- return ReflectDependencies(self._instance).getMethodDependencies(method_name)