orionis 0.435.0__py3-none-any.whl → 0.437.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 (59) hide show
  1. orionis/console/contracts/kernel.py +16 -3
  2. orionis/console/dumper/contracts/dump.py +8 -9
  3. orionis/console/dynamic/progress_bar.py +21 -29
  4. orionis/console/output/console.py +12 -0
  5. orionis/container/context/manager.py +27 -17
  6. orionis/container/context/scope.py +8 -7
  7. orionis/container/contracts/service_provider.py +12 -8
  8. orionis/container/providers/service_provider.py +9 -16
  9. orionis/container/resolver/resolver.py +29 -22
  10. orionis/foundation/contracts/application.py +437 -47
  11. orionis/foundation/contracts/config.py +14 -6
  12. orionis/foundation/providers/console_provider.py +16 -15
  13. orionis/foundation/providers/dumper_provider.py +20 -8
  14. orionis/foundation/providers/logger_provider.py +19 -14
  15. orionis/foundation/providers/path_resolver_provider.py +17 -14
  16. orionis/foundation/providers/progress_bar_provider.py +15 -14
  17. orionis/foundation/providers/testing_provider.py +20 -14
  18. orionis/foundation/providers/workers_provider.py +19 -14
  19. orionis/metadata/framework.py +1 -1
  20. orionis/services/asynchrony/contracts/coroutines.py +5 -9
  21. orionis/services/asynchrony/coroutines.py +10 -23
  22. orionis/services/asynchrony/exceptions/exception.py +3 -3
  23. orionis/services/environment/contracts/caster.py +8 -9
  24. orionis/services/environment/contracts/env.py +9 -9
  25. orionis/services/environment/core/dot_env.py +56 -71
  26. orionis/services/environment/dynamic/caster.py +215 -215
  27. orionis/services/environment/enums/__init__.py +5 -0
  28. orionis/services/environment/enums/value_type.py +22 -25
  29. orionis/services/environment/env.py +28 -12
  30. orionis/services/environment/exceptions/exception.py +6 -2
  31. orionis/services/environment/exceptions/value.py +6 -2
  32. orionis/services/environment/helpers/functions.py +5 -3
  33. orionis/services/environment/key/key_generator.py +8 -11
  34. orionis/services/environment/validators/__init__.py +7 -0
  35. orionis/services/environment/validators/key_name.py +5 -5
  36. orionis/services/environment/validators/types.py +29 -9
  37. orionis/services/introspection/abstract/contracts/reflection.py +188 -221
  38. orionis/services/introspection/abstract/reflection.py +311 -178
  39. orionis/services/introspection/callables/contracts/reflection.py +64 -21
  40. orionis/services/introspection/callables/reflection.py +98 -23
  41. orionis/services/introspection/concretes/reflection.py +278 -181
  42. orionis/services/introspection/dependencies/contracts/reflection.py +21 -18
  43. orionis/services/introspection/dependencies/entities/callable_dependencies.py +15 -16
  44. orionis/services/introspection/dependencies/entities/class_dependencies.py +24 -16
  45. orionis/services/introspection/dependencies/entities/known_dependencies.py +19 -13
  46. orionis/services/introspection/dependencies/entities/method_dependencies.py +22 -16
  47. orionis/services/introspection/dependencies/reflection.py +0 -3
  48. orionis/services/introspection/instances/reflection.py +16 -6
  49. orionis/services/log/contracts/log_service.py +4 -0
  50. orionis/services/log/handlers/filename.py +2 -0
  51. orionis/services/paths/contracts/resolver.py +0 -3
  52. orionis/services/paths/resolver.py +0 -3
  53. {orionis-0.435.0.dist-info → orionis-0.437.0.dist-info}/METADATA +1 -1
  54. {orionis-0.435.0.dist-info → orionis-0.437.0.dist-info}/RECORD +59 -59
  55. /orionis/services/introspection/concretes/contracts/{concrete.py → reflection.py} +0 -0
  56. {orionis-0.435.0.dist-info → orionis-0.437.0.dist-info}/WHEEL +0 -0
  57. {orionis-0.435.0.dist-info → orionis-0.437.0.dist-info}/licenses/LICENCE +0 -0
  58. {orionis-0.435.0.dist-info → orionis-0.437.0.dist-info}/top_level.txt +0 -0
  59. {orionis-0.435.0.dist-info → orionis-0.437.0.dist-info}/zip-safe +0 -0
@@ -3,7 +3,7 @@ import inspect
3
3
  import keyword
4
4
  from typing import Any, Callable, List, Type
5
5
  from orionis.services.asynchrony.coroutines import Coroutine
6
- from orionis.services.introspection.concretes.contracts.concrete import IReflectionConcrete
6
+ from orionis.services.introspection.concretes.contracts.reflection import IReflectionConcrete
7
7
  from orionis.services.introspection.dependencies.entities.class_dependencies import ClassDependency
8
8
  from orionis.services.introspection.dependencies.entities.method_dependencies import MethodDependency
9
9
  from orionis.services.introspection.dependencies.reflection import ReflectDependencies
@@ -15,21 +15,29 @@ from orionis.services.introspection.exceptions import (
15
15
  from orionis.services.introspection.instances.reflection import ReflectionInstance
16
16
 
17
17
  class ReflectionConcrete(IReflectionConcrete):
18
+ """
19
+ A concrete implementation for reflecting on class types and their members.
20
+
21
+ This class provides comprehensive introspection capabilities for analyzing class
22
+ structures, attributes, methods, properties, and dependencies. It supports
23
+ dynamic manipulation of class members while maintaining type safety and
24
+ validation.
25
+ """
18
26
 
19
27
  @staticmethod
20
28
  def isConcreteClass(concrete: Type) -> bool:
21
29
  """
22
- Checks if the provided concrete type is a valid ReflectionConcrete type.
30
+ Check if the provided type is a valid concrete class for reflection.
23
31
 
24
32
  Parameters
25
33
  ----------
26
34
  concrete : Type
27
- The class type to be validated.
35
+ The class type to validate for reflection compatibility.
28
36
 
29
37
  Returns
30
38
  -------
31
39
  bool
32
- True if the class is a valid ReflectionConcrete type, False otherwise.
40
+ True if the class is valid for reflection, False otherwise.
33
41
  """
34
42
  try:
35
43
  return ReflectionConcrete.ensureIsConcreteClass(concrete)
@@ -39,20 +47,30 @@ class ReflectionConcrete(IReflectionConcrete):
39
47
  @staticmethod
40
48
  def ensureIsConcreteClass(concrete: Type) -> bool:
41
49
  """
42
- Ensures that the provided concrete type is a valid ReflectionConcrete type.
50
+ Validate that the provided type is a concrete class suitable for reflection.
51
+
52
+ This method performs comprehensive validation to ensure the type can be
53
+ safely used for reflection operations. It checks for proper class type,
54
+ excludes built-in types, and prevents abstract classes.
43
55
 
44
56
  Parameters
45
57
  ----------
46
58
  concrete : Type
47
- The class type to be validated.
59
+ The class type to validate.
60
+
61
+ Returns
62
+ -------
63
+ bool
64
+ True if validation passes.
48
65
 
49
66
  Raises
50
67
  ------
51
68
  ReflectionTypeError
52
- If the provided argument is not a class type or is already an instance.
69
+ If the argument is not a class type or is an instance.
53
70
  ReflectionValueError
54
- If the provided class is a built-in/primitive type, abstract class, or interface.
71
+ If the class is built-in, primitive, abstract, or an interface.
55
72
  """
73
+
56
74
  # Check if the concrete is a class type
57
75
  if not isinstance(concrete, type):
58
76
  raise ReflectionTypeError(f"Expected a class, got {type(concrete)}")
@@ -83,24 +101,27 @@ class ReflectionConcrete(IReflectionConcrete):
83
101
 
84
102
  def __init__(self, concrete: Type) -> None:
85
103
  """
86
- Initialize the ReflectionConcrete with the provided class type.
104
+ Initialize the reflection concrete with a validated class type.
105
+
106
+ Performs validation on the provided class type and initializes the
107
+ reflection instance with the concrete class for subsequent operations.
87
108
 
88
109
  Parameters
89
110
  ----------
90
111
  concrete : Type
91
- The class type to be reflected upon.
112
+ The class type to reflect upon.
92
113
 
93
114
  Raises
94
115
  ------
95
116
  ReflectionTypeError
96
- If the provided argument is not a class type or is already an instance.
117
+ If the argument is not a class type or is an instance.
97
118
  ReflectionValueError
98
- If the provided class is a built-in/primitive type, abstract class, or interface.
119
+ If the class is built-in, primitive, abstract, or an interface.
99
120
 
100
121
  Notes
101
122
  -----
102
- - Built-in and primitive types (e.g., int, str, list) are not allowed.
103
- - Abstract classes and interfaces (classes with abstract methods) are not allowed.
123
+ Built-in and primitive types (e.g., int, str, list) are not allowed.
124
+ Abstract classes and interfaces (classes with abstract methods) are not allowed.
104
125
  """
105
126
 
106
127
  # Ensure the provided concrete type is a valid ReflectionConcrete class
@@ -112,7 +133,11 @@ class ReflectionConcrete(IReflectionConcrete):
112
133
 
113
134
  def getInstance(self, *args, **kwargs):
114
135
  """
115
- Returns an instance of the reflected class.
136
+ Create and return an instance of the reflected class.
137
+
138
+ Instantiates the reflected class using the provided arguments and
139
+ performs validation to ensure the instance is compatible with
140
+ reflection operations.
116
141
 
117
142
  Parameters
118
143
  ----------
@@ -124,13 +149,14 @@ class ReflectionConcrete(IReflectionConcrete):
124
149
  Returns
125
150
  -------
126
151
  object
127
- An instance of the class type provided during initialization.
152
+ An instance of the reflected class.
128
153
 
129
154
  Raises
130
155
  ------
131
156
  ReflectionValueError
132
- If instantiation fails or if the class defines an asynchronous __str__ method.
157
+ If instantiation fails or the class has an asynchronous __str__ method.
133
158
  """
159
+
134
160
  try:
135
161
 
136
162
  # Try to instantiate the class
@@ -156,7 +182,7 @@ class ReflectionConcrete(IReflectionConcrete):
156
182
 
157
183
  def getClass(self) -> Type:
158
184
  """
159
- Returns the class type that this reflection concrete is based on.
185
+ Get the class type being reflected upon.
160
186
 
161
187
  Returns
162
188
  -------
@@ -167,72 +193,72 @@ class ReflectionConcrete(IReflectionConcrete):
167
193
 
168
194
  def getClassName(self) -> str:
169
195
  """
170
- Returns the name of the class type.
196
+ Get the name of the reflected class.
171
197
 
172
198
  Returns
173
199
  -------
174
200
  str
175
- The name of the class type.
201
+ The simple name of the class without module qualification.
176
202
  """
177
203
  return self._concrete.__name__
178
204
 
179
205
  def getModuleName(self) -> str:
180
206
  """
181
- Returns the name of the module where the class is defined.
207
+ Get the module name where the reflected class is defined.
182
208
 
183
209
  Returns
184
210
  -------
185
211
  str
186
- The name of the module.
212
+ The fully qualified module name containing the class.
187
213
  """
188
214
  return self._concrete.__module__
189
215
 
190
216
  def getModuleWithClassName(self) -> str:
191
217
  """
192
- Returns the module name concatenated with the class name.
218
+ Get the fully qualified class name including module path.
193
219
 
194
220
  Returns
195
221
  -------
196
222
  str
197
- The module name followed by the class name.
223
+ The module name concatenated with the class name, separated by a dot.
198
224
  """
199
225
  return f"{self.getModuleName()}.{self.getClassName()}"
200
226
 
201
227
  def getDocstring(self) -> str:
202
228
  """
203
- Returns the docstring of the class.
229
+ Get the docstring of the reflected class.
204
230
 
205
231
  Returns
206
232
  -------
207
233
  str or None
208
- The docstring of the class, or None if not defined.
234
+ The class docstring if defined, None otherwise.
209
235
  """
210
236
  return self._concrete.__doc__ if self._concrete.__doc__ else None
211
237
 
212
238
  def getBaseClasses(self) -> list:
213
239
  """
214
- Returns a list of base classes of the reflected class.
240
+ Get all base classes of the reflected class.
215
241
 
216
242
  Returns
217
243
  -------
218
244
  list
219
- A list of base classes.
245
+ A list containing all base classes in the method resolution order.
220
246
  """
221
247
  return self._concrete.__bases__
222
248
 
223
249
  def getSourceCode(self) -> str:
224
250
  """
225
- Returns the source code of the class.
251
+ Get the source code of the reflected class.
226
252
 
227
253
  Returns
228
254
  -------
229
255
  str
230
- The source code of the class.
256
+ The complete source code of the class definition.
231
257
 
232
258
  Raises
233
259
  ------
234
260
  ReflectionValueError
235
- If the source code cannot be retrieved.
261
+ If the source code cannot be retrieved (e.g., built-in classes).
236
262
  """
237
263
  try:
238
264
  return inspect.getsource(self._concrete)
@@ -241,17 +267,17 @@ class ReflectionConcrete(IReflectionConcrete):
241
267
 
242
268
  def getFile(self) -> str:
243
269
  """
244
- Returns the file path where the class is defined.
270
+ Get the file path where the reflected class is defined.
245
271
 
246
272
  Returns
247
273
  -------
248
274
  str
249
- The file path of the class definition.
275
+ The absolute file path containing the class definition.
250
276
 
251
277
  Raises
252
278
  ------
253
279
  ReflectionValueError
254
- If the file path cannot be retrieved.
280
+ If the file path cannot be determined (e.g., dynamically created classes).
255
281
  """
256
282
  try:
257
283
  return inspect.getfile(self._concrete)
@@ -260,37 +286,41 @@ class ReflectionConcrete(IReflectionConcrete):
260
286
 
261
287
  def getAnnotations(self) -> dict:
262
288
  """
263
- Returns the type annotations of the class.
289
+ Get type annotations defined on the reflected class.
290
+
291
+ Processes and returns the type annotations with proper name mangling
292
+ resolution for private attributes.
264
293
 
265
294
  Returns
266
295
  -------
267
296
  dict
268
- A dictionary of type annotations.
297
+ A dictionary mapping attribute names to their type annotations.
269
298
  """
270
299
  annotations = {}
271
300
  for k, v in getattr(self._concrete, '__annotations__', {}).items():
301
+ # Remove private attribute name mangling for cleaner output
272
302
  annotations[str(k).replace(f"_{self.getClassName()}", "")] = v
273
303
  return annotations
274
304
 
275
305
  def hasAttribute(self, attribute: str) -> bool:
276
306
  """
277
- Checks if the class has a specific attribute.
307
+ Check if the reflected class has a specific attribute.
278
308
 
279
309
  Parameters
280
310
  ----------
281
311
  attribute : str
282
- The name of the attribute to check.
312
+ The name of the attribute to check for.
283
313
 
284
314
  Returns
285
315
  -------
286
316
  bool
287
- True if the class has the specified attribute, False otherwise.
317
+ True if the attribute exists, False otherwise.
288
318
  """
289
319
  return attribute in self.getAttributes()
290
320
 
291
321
  def getAttribute(self, attribute: str):
292
322
  """
293
- Returns the value of a specific class attribute.
323
+ Get the value of a specific class attribute.
294
324
 
295
325
  Parameters
296
326
  ----------
@@ -300,7 +330,7 @@ class ReflectionConcrete(IReflectionConcrete):
300
330
  Returns
301
331
  -------
302
332
  Any
303
- The value of the specified class attribute.
333
+ The value of the specified attribute, or None if not found.
304
334
 
305
335
  Raises
306
336
  ------
@@ -312,19 +342,27 @@ class ReflectionConcrete(IReflectionConcrete):
312
342
 
313
343
  def setAttribute(self, name: str, value) -> bool:
314
344
  """
315
- Set an attribute value.
345
+ Set a class attribute to the specified value.
346
+
347
+ Validates the attribute name and value before setting. Handles private
348
+ attribute name mangling automatically.
316
349
 
317
350
  Parameters
318
351
  ----------
319
352
  name : str
320
- The attribute name
353
+ The name of the attribute to set.
321
354
  value : Any
322
- The value to set
355
+ The value to assign to the attribute.
356
+
357
+ Returns
358
+ -------
359
+ bool
360
+ True if the attribute was successfully set.
323
361
 
324
362
  Raises
325
363
  ------
326
364
  ReflectionValueError
327
- If the attribute is read-only or invalid
365
+ If the attribute name is invalid or the value is callable.
328
366
  """
329
367
 
330
368
  # Ensure the name is a valid attr name with regular expression
@@ -347,18 +385,27 @@ class ReflectionConcrete(IReflectionConcrete):
347
385
 
348
386
  def removeAttribute(self, name: str) -> bool:
349
387
  """
350
- Remove an attribute from the class.
388
+ Remove an attribute from the reflected class.
389
+
390
+ Handles private attribute name mangling automatically before removal.
351
391
 
352
392
  Parameters
353
393
  ----------
354
394
  name : str
355
395
  The name of the attribute to remove.
356
396
 
397
+ Returns
398
+ -------
399
+ bool
400
+ True if the attribute was successfully removed.
401
+
357
402
  Raises
358
403
  ------
359
404
  ReflectionValueError
360
405
  If the attribute does not exist or cannot be removed.
361
406
  """
407
+
408
+ # Check if the attribute exists
362
409
  if not self.hasAttribute(name):
363
410
  raise ReflectionValueError(f"Attribute '{name}' does not exist in class '{self.getClassName()}'.")
364
411
 
@@ -367,25 +414,27 @@ class ReflectionConcrete(IReflectionConcrete):
367
414
  class_name = self.getClassName()
368
415
  name = f"_{class_name}{name}"
369
416
 
417
+ # Delete the attribute from the class itself
370
418
  delattr(self._concrete, name)
371
419
 
420
+ # Return True to indicate successful removal
372
421
  return True
373
422
 
374
423
  def getAttributes(self) -> dict:
375
424
  """
376
- Returns a dictionary of all class attributes (not instance attributes).
425
+ Get all class attributes regardless of visibility.
377
426
 
378
- Parameters
379
- ----------
380
- None
427
+ Combines public, protected, private, and dunder attributes into a
428
+ single dictionary for comprehensive attribute access.
381
429
 
382
430
  Returns
383
431
  -------
384
432
  dict
385
- A dictionary where keys are the names of class attributes and values are their corresponding values.
386
- Only attributes that are not callable, not static/class methods, not properties, and do not start with
387
- underscores (including dunder, protected, or private) are included.
433
+ A dictionary mapping attribute names to their values, including
434
+ all visibility levels (public, protected, private, dunder).
388
435
  """
436
+
437
+ # Combine all attribute types into a single dictionary
389
438
  return {
390
439
  **self.getPublicAttributes(),
391
440
  **self.getProtectedAttributes(),
@@ -395,18 +444,16 @@ class ReflectionConcrete(IReflectionConcrete):
395
444
 
396
445
  def getPublicAttributes(self) -> dict:
397
446
  """
398
- Returns a dictionary of public class attributes (not instance attributes).
447
+ Get all public class attributes.
399
448
 
400
- Parameters
401
- ----------
402
- None
449
+ Retrieves class attributes that do not start with underscores,
450
+ excluding callables, static methods, class methods, and properties.
403
451
 
404
452
  Returns
405
453
  -------
406
454
  dict
407
- A dictionary where keys are the names of public class attributes and values are their corresponding values.
408
- Only attributes that are not callable, not static/class methods, not properties, and do not start with
409
- underscores (including dunder, protected, or private) are included.
455
+ A dictionary mapping public attribute names to their values.
456
+ Excludes dunder, protected, and private attributes.
410
457
  """
411
458
  class_name = self.getClassName()
412
459
  attributes = self._concrete.__dict__
@@ -428,18 +475,16 @@ class ReflectionConcrete(IReflectionConcrete):
428
475
 
429
476
  def getProtectedAttributes(self) -> dict:
430
477
  """
431
- Returns a dictionary of protected class attributes (not instance attributes).
478
+ Get all protected class attributes.
432
479
 
433
- Parameters
434
- ----------
435
- None
480
+ Retrieves class attributes that start with a single underscore,
481
+ indicating protected visibility in Python convention.
436
482
 
437
483
  Returns
438
484
  -------
439
485
  dict
440
- A dictionary where keys are the names of protected class attributes and values are their corresponding values.
441
- Only attributes that are not callable, not static/class methods, not properties, and start with a single underscore
442
- (indicating protected visibility) are included.
486
+ A dictionary mapping protected attribute names to their values.
487
+ Includes only attributes starting with single underscore.
443
488
  """
444
489
  class_name = self.getClassName()
445
490
  attributes = self._concrete.__dict__
@@ -461,18 +506,16 @@ class ReflectionConcrete(IReflectionConcrete):
461
506
 
462
507
  def getPrivateAttributes(self) -> dict:
463
508
  """
464
- Returns a dictionary of private class attributes (not instance attributes).
509
+ Get all private class attributes.
465
510
 
466
- Parameters
467
- ----------
468
- None
511
+ Retrieves class attributes that use Python's name mangling convention
512
+ for private attributes (double underscore prefix).
469
513
 
470
514
  Returns
471
515
  -------
472
516
  dict
473
- A dictionary where keys are the names of private class attributes and values are their corresponding values.
474
- Only attributes that are not callable, not static/class methods, not properties, and start with double underscores
475
- (indicating private visibility) are included.
517
+ A dictionary mapping private attribute names (with mangling removed)
518
+ to their values.
476
519
  """
477
520
  class_name = self.getClassName()
478
521
  attributes = self._concrete.__dict__
@@ -483,24 +526,23 @@ class ReflectionConcrete(IReflectionConcrete):
483
526
  if callable(value) or isinstance(value, staticmethod) or isinstance(value, classmethod) or isinstance(value, property):
484
527
  continue
485
528
  if attr.startswith(f"_{class_name}"):
529
+ # Remove name mangling for cleaner output
486
530
  private[str(attr).replace(f"_{class_name}", "")] = value
487
531
 
488
532
  return private
489
533
 
490
534
  def getDunderAttributes(self) -> dict:
491
535
  """
492
- Returns a dictionary of dunder (double underscore) class attributes (not instance attributes).
536
+ Get all dunder (magic) class attributes.
493
537
 
494
- Parameters
495
- ----------
496
- None
538
+ Retrieves class attributes that follow the double underscore naming
539
+ convention, excluding common built-in dunder attributes.
497
540
 
498
541
  Returns
499
542
  -------
500
543
  dict
501
- A dictionary where keys are the names of dunder class attributes and values are their corresponding values.
502
- Only attributes that are not callable, not static/class methods, not properties, and start with double underscores
503
- (indicating dunder visibility) are included.
544
+ A dictionary mapping dunder attribute names to their values.
545
+ Excludes standard Python dunder attributes like __class__, __dict__, etc.
504
546
  """
505
547
  attributes = self._concrete.__dict__
506
548
  dunder = {}
@@ -526,59 +568,59 @@ class ReflectionConcrete(IReflectionConcrete):
526
568
 
527
569
  def getMagicAttributes(self) -> dict:
528
570
  """
529
- Returns a dictionary of magic (dunder) class attributes (not instance attributes).
571
+ Get all magic (dunder) class attributes.
530
572
 
531
- Parameters
532
- ----------
533
- None
573
+ This is an alias for getDunderAttributes() providing alternative naming
574
+ for accessing double underscore attributes.
534
575
 
535
576
  Returns
536
577
  -------
537
578
  dict
538
- A dictionary where keys are the names of magic class attributes and values are their corresponding values.
539
- Only attributes that are not callable, not static/class methods, not properties, and start with double underscores
540
- (indicating magic visibility) are included.
579
+ A dictionary mapping magic attribute names to their values.
541
580
  """
542
581
  return self.getDunderAttributes()
543
582
 
544
583
  def hasMethod(self, name: str) -> bool:
545
584
  """
546
- Check if the instance has a specific method.
585
+ Check if the reflected class has a specific method.
547
586
 
548
587
  Parameters
549
588
  ----------
550
589
  name : str
551
- The method name to check
590
+ The name of the method to check for.
552
591
 
553
592
  Returns
554
593
  -------
555
594
  bool
556
- True if the method exists, False otherwise
595
+ True if the method exists in the class, False otherwise.
557
596
  """
558
597
  return name in self.getMethods()
559
598
 
560
599
  def callMethod(self, name: str, *args, **kwargs):
561
600
  """
562
- Call a method of the instance with the provided arguments.
601
+ Call a method on the class instance with provided arguments.
602
+
603
+ Requires that an instance has been created using getInstance().
604
+ Automatically handles asynchronous methods using the Coroutine wrapper.
563
605
 
564
606
  Parameters
565
607
  ----------
566
608
  name : str
567
- The method name to call
609
+ The name of the method to call.
568
610
  *args : tuple
569
- Positional arguments to pass to the method
611
+ Positional arguments to pass to the method.
570
612
  **kwargs : dict
571
- Keyword arguments to pass to the method
613
+ Keyword arguments to pass to the method.
572
614
 
573
615
  Returns
574
616
  -------
575
617
  Any
576
- The return value of the method call
618
+ The return value of the method call.
577
619
 
578
620
  Raises
579
621
  ------
580
622
  ReflectionValueError
581
- If the method does not exist or is not callable.
623
+ If the method does not exist, instance is not initialized, or method call fails.
582
624
  """
583
625
  if not self.hasMethod(name):
584
626
  raise ReflectionValueError(f"Method '{name}' does not exist in class '{self.getClassName()}'.")
@@ -599,19 +641,27 @@ class ReflectionConcrete(IReflectionConcrete):
599
641
 
600
642
  def setMethod(self, name: str, method: Callable) -> bool:
601
643
  """
602
- Set a method on the class.
644
+ Add a new method to the reflected class.
645
+
646
+ Validates the method name and callable before adding it to the class.
647
+ Handles private method name mangling automatically.
603
648
 
604
649
  Parameters
605
650
  ----------
606
651
  name : str
607
- The method name to set
608
- method : callable
609
- The method to set
652
+ The name for the new method.
653
+ method : Callable
654
+ The callable object to set as a method.
655
+
656
+ Returns
657
+ -------
658
+ bool
659
+ True if the method was successfully added.
610
660
 
611
661
  Raises
612
662
  ------
613
663
  ReflectionValueError
614
- If the method is not callable or if the name is invalid.
664
+ If the method name already exists, is invalid, or the object is not callable.
615
665
  """
616
666
  # Check if the method already exists
617
667
  if name in self.getMethods():
@@ -637,12 +687,19 @@ class ReflectionConcrete(IReflectionConcrete):
637
687
 
638
688
  def removeMethod(self, name: str) -> bool:
639
689
  """
640
- Remove a method from the class.
690
+ Remove a method from the reflected class.
691
+
692
+ Handles private method name mangling automatically before removal.
641
693
 
642
694
  Parameters
643
695
  ----------
644
696
  name : str
645
- The method name to remove
697
+ The name of the method to remove.
698
+
699
+ Returns
700
+ -------
701
+ bool
702
+ True if the method was successfully removed.
646
703
 
647
704
  Raises
648
705
  ------
@@ -665,17 +722,17 @@ class ReflectionConcrete(IReflectionConcrete):
665
722
 
666
723
  def getMethodSignature(self, name: str) -> inspect.Signature:
667
724
  """
668
- Get the signature of a method.
725
+ Get the signature of a specific method.
669
726
 
670
727
  Parameters
671
728
  ----------
672
729
  name : str
673
- The method name to get the signature for
730
+ The name of the method to inspect.
674
731
 
675
732
  Returns
676
733
  -------
677
- str
678
- The signature of the method
734
+ inspect.Signature
735
+ The signature object containing parameter and return information.
679
736
 
680
737
  Raises
681
738
  ------
@@ -696,12 +753,15 @@ class ReflectionConcrete(IReflectionConcrete):
696
753
 
697
754
  def getMethods(self) -> List[str]:
698
755
  """
699
- Get all method names of the instance.
756
+ Get all method names from the reflected class.
757
+
758
+ Combines all types of methods including instance methods, class methods,
759
+ and static methods with different visibility levels.
700
760
 
701
761
  Returns
702
762
  -------
703
763
  List[str]
704
- List of method names
764
+ A comprehensive list of all method names in the class.
705
765
  """
706
766
  return [
707
767
  *self.getPublicMethods(),
@@ -717,16 +777,15 @@ class ReflectionConcrete(IReflectionConcrete):
717
777
 
718
778
  def getPublicMethods(self) -> list:
719
779
  """
720
- Returns a list of public class methods (not instance methods).
780
+ Get all public instance method names from the reflected class.
721
781
 
722
- Parameters
723
- ----------
724
- None
782
+ Retrieves methods that are callable, not static or class methods,
783
+ not properties, and do not start with underscores.
725
784
 
726
785
  Returns
727
786
  -------
728
- dict
729
- A list where each element is the name of a public class method.
787
+ list
788
+ A list of public instance method names.
730
789
  """
731
790
  class_name = self.getClassName()
732
791
  attributes = self._concrete.__dict__
@@ -747,12 +806,14 @@ class ReflectionConcrete(IReflectionConcrete):
747
806
 
748
807
  def getPublicSyncMethods(self) -> list:
749
808
  """
750
- Get all public synchronous method names of the class.
809
+ Get all public synchronous method names from the reflected class.
810
+
811
+ Filters public methods to include only those that are not coroutine functions.
751
812
 
752
813
  Returns
753
814
  -------
754
815
  list
755
- List of public synchronous method names
816
+ A list of public synchronous method names.
756
817
  """
757
818
  methods = self.getPublicMethods()
758
819
  sync_methods = []
@@ -763,12 +824,14 @@ class ReflectionConcrete(IReflectionConcrete):
763
824
 
764
825
  def getPublicAsyncMethods(self) -> list:
765
826
  """
766
- Get all public asynchronous method names of the class.
827
+ Get all public asynchronous method names from the reflected class.
828
+
829
+ Filters public methods to include only those that are coroutine functions.
767
830
 
768
831
  Returns
769
832
  -------
770
833
  list
771
- List of public asynchronous method names
834
+ A list of public asynchronous method names.
772
835
  """
773
836
  methods = self.getPublicMethods()
774
837
  async_methods = []
@@ -779,16 +842,15 @@ class ReflectionConcrete(IReflectionConcrete):
779
842
 
780
843
  def getProtectedMethods(self) -> list:
781
844
  """
782
- Returns a list of protected class methods (not instance methods).
845
+ Get all protected instance method names from the reflected class.
783
846
 
784
- Parameters
785
- ----------
786
- None
847
+ Retrieves methods that start with a single underscore, indicating
848
+ protected visibility according to Python naming conventions.
787
849
 
788
850
  Returns
789
851
  -------
790
- dict
791
- A list where each element is the name of a protected class method.
852
+ list
853
+ A list of protected instance method names.
792
854
  """
793
855
  class_name = self.getClassName()
794
856
  attributes = self._concrete.__dict__
@@ -804,12 +866,14 @@ class ReflectionConcrete(IReflectionConcrete):
804
866
 
805
867
  def getProtectedSyncMethods(self) -> list:
806
868
  """
807
- Get all protected synchronous method names of the class.
869
+ Get all protected synchronous method names from the reflected class.
870
+
871
+ Filters protected methods to include only those that are not coroutine functions.
808
872
 
809
873
  Returns
810
874
  -------
811
875
  list
812
- List of protected synchronous method names
876
+ A list of protected synchronous method names.
813
877
  """
814
878
  methods = self.getProtectedMethods()
815
879
  sync_methods = []
@@ -820,12 +884,14 @@ class ReflectionConcrete(IReflectionConcrete):
820
884
 
821
885
  def getProtectedAsyncMethods(self) -> list:
822
886
  """
823
- Get all protected asynchronous method names of the class.
887
+ Get all protected asynchronous method names from the reflected class.
888
+
889
+ Filters protected methods to include only those that are coroutine functions.
824
890
 
825
891
  Returns
826
892
  -------
827
893
  list
828
- List of protected asynchronous method names
894
+ A list of protected asynchronous method names.
829
895
  """
830
896
  methods = self.getProtectedMethods()
831
897
  async_methods = []
@@ -836,16 +902,15 @@ class ReflectionConcrete(IReflectionConcrete):
836
902
 
837
903
  def getPrivateMethods(self) -> list:
838
904
  """
839
- Returns a list of private class methods (not instance methods).
905
+ Get all private instance method names from the reflected class.
840
906
 
841
- Parameters
842
- ----------
843
- None
907
+ Retrieves methods that use Python's name mangling convention
908
+ for private methods (class name prefix), with name mangling resolved.
844
909
 
845
910
  Returns
846
911
  -------
847
912
  list
848
- A list where each element is the name of a private class method.
913
+ A list of private instance method names with mangling removed.
849
914
  """
850
915
  class_name = self.getClassName()
851
916
  attributes = self._concrete.__dict__
@@ -855,6 +920,7 @@ class ReflectionConcrete(IReflectionConcrete):
855
920
  for attr, value in attributes.items():
856
921
  if callable(value) and not isinstance(value, (staticmethod, classmethod)) and not isinstance(value, property):
857
922
  if attr.startswith(f"_{class_name}"):
923
+ # Remove name mangling for cleaner output
858
924
  private_methods.append(str(attr).replace(f"_{class_name}", ""))
859
925
 
860
926
  return private_methods
@@ -1245,16 +1311,15 @@ class ReflectionConcrete(IReflectionConcrete):
1245
1311
 
1246
1312
  def getDunderMethods(self) -> list:
1247
1313
  """
1248
- Returns a list of dunder (double underscore) methods of the class.
1314
+ Get all dunder (magic) method names from the reflected class.
1249
1315
 
1250
- Parameters
1251
- ----------
1252
- None
1316
+ Retrieves methods that follow the double underscore naming convention,
1317
+ excluding built-in Python methods and non-callable attributes.
1253
1318
 
1254
1319
  Returns
1255
1320
  -------
1256
1321
  list
1257
- A list where each element is the name of a dunder method.
1322
+ A list of dunder method names available in the class.
1258
1323
  """
1259
1324
  attributes = self._concrete.__dict__
1260
1325
  dunder_methods = []
@@ -1270,44 +1335,49 @@ class ReflectionConcrete(IReflectionConcrete):
1270
1335
 
1271
1336
  def getMagicMethods(self) -> list:
1272
1337
  """
1273
- Returns a list of magic (dunder) methods of the class.
1338
+ Get all magic (dunder) method names from the reflected class.
1274
1339
 
1275
- Parameters
1276
- ----------
1277
- None
1340
+ This is an alias for getDunderMethods() providing alternative naming
1341
+ for accessing double underscore methods.
1278
1342
 
1279
1343
  Returns
1280
1344
  -------
1281
1345
  list
1282
- A list where each element is the name of a magic method.
1346
+ A list of magic method names available in the class.
1283
1347
  """
1284
1348
  return self.getDunderMethods()
1285
1349
 
1286
1350
  def getProperties(self) -> List:
1287
1351
  """
1288
- Get all properties of the instance.
1352
+ Get all property names from the reflected class.
1353
+
1354
+ Scans the class dictionary for property objects and returns their names
1355
+ with private attribute name mangling resolved.
1289
1356
 
1290
1357
  Returns
1291
1358
  -------
1292
1359
  List[str]
1293
- List of property names
1360
+ A list of all property names in the class.
1294
1361
  """
1295
-
1296
1362
  properties = []
1297
1363
  for name, prop in self._concrete.__dict__.items():
1298
1364
  if isinstance(prop, property):
1365
+ # Remove private attribute name mangling for cleaner output
1299
1366
  name_prop = name.replace(f"_{self.getClassName()}", "")
1300
1367
  properties.append(name_prop)
1301
1368
  return properties
1302
1369
 
1303
1370
  def getPublicProperties(self) -> List:
1304
1371
  """
1305
- Get all public properties of the instance.
1372
+ Get all public property names from the reflected class.
1373
+
1374
+ Retrieves properties that do not start with underscores, indicating
1375
+ public visibility according to Python naming conventions.
1306
1376
 
1307
1377
  Returns
1308
1378
  -------
1309
- List:
1310
- List of public property names and their values
1379
+ List[str]
1380
+ A list of public property names with name mangling resolved.
1311
1381
  """
1312
1382
  properties = []
1313
1383
  cls_name = self.getClassName()
@@ -1319,12 +1389,15 @@ class ReflectionConcrete(IReflectionConcrete):
1319
1389
 
1320
1390
  def getProtectedProperties(self) -> List:
1321
1391
  """
1322
- Get all protected properties of the instance.
1392
+ Get all protected property names from the reflected class.
1393
+
1394
+ Retrieves properties that start with a single underscore but are not
1395
+ private (double underscore) attributes.
1323
1396
 
1324
1397
  Returns
1325
1398
  -------
1326
- List
1327
- List of protected property names and their values
1399
+ List[str]
1400
+ A list of protected property names.
1328
1401
  """
1329
1402
  properties = []
1330
1403
  for name, prop in self._concrete.__dict__.items():
@@ -1335,12 +1408,15 @@ class ReflectionConcrete(IReflectionConcrete):
1335
1408
 
1336
1409
  def getPrivateProperties(self) -> List:
1337
1410
  """
1338
- Get all private properties of the instance.
1411
+ Get all private property names from the reflected class.
1412
+
1413
+ Retrieves properties that use Python's name mangling convention
1414
+ for private attributes (class name prefix).
1339
1415
 
1340
1416
  Returns
1341
1417
  -------
1342
- List
1343
- List of private property names and their values
1418
+ List[str]
1419
+ A list of private property names with name mangling resolved.
1344
1420
  """
1345
1421
  properties = []
1346
1422
  for name, prop in self._concrete.__dict__.items():
@@ -1351,17 +1427,20 @@ class ReflectionConcrete(IReflectionConcrete):
1351
1427
 
1352
1428
  def getProperty(self, name: str) -> Any:
1353
1429
  """
1354
- Get a specific property of the instance.
1430
+ Get the value of a specific property from the reflected class.
1431
+
1432
+ Handles private property name mangling and validates that the
1433
+ requested attribute is actually a property object.
1355
1434
 
1356
1435
  Parameters
1357
1436
  ----------
1358
1437
  name : str
1359
- The name of the property to retrieve
1438
+ The name of the property to retrieve.
1360
1439
 
1361
1440
  Returns
1362
1441
  -------
1363
1442
  Any
1364
- The value of the property
1443
+ The current value of the property.
1365
1444
 
1366
1445
  Raises
1367
1446
  ------
@@ -1384,17 +1463,17 @@ class ReflectionConcrete(IReflectionConcrete):
1384
1463
 
1385
1464
  def getPropertySignature(self, name: str) -> inspect.Signature:
1386
1465
  """
1387
- Get the signature of a property.
1466
+ Get the signature of a specific property's getter method.
1388
1467
 
1389
1468
  Parameters
1390
1469
  ----------
1391
1470
  name : str
1392
- The property name to get the signature for
1471
+ The name of the property to inspect.
1393
1472
 
1394
1473
  Returns
1395
1474
  -------
1396
1475
  inspect.Signature
1397
- The signature of the property
1476
+ The signature of the property's getter function.
1398
1477
 
1399
1478
  Raises
1400
1479
  ------
@@ -1417,17 +1496,17 @@ class ReflectionConcrete(IReflectionConcrete):
1417
1496
 
1418
1497
  def getPropertyDocstring(self, name: str) -> str:
1419
1498
  """
1420
- Get the docstring of a property.
1499
+ Get the docstring of a specific property's getter method.
1421
1500
 
1422
1501
  Parameters
1423
1502
  ----------
1424
1503
  name : str
1425
- The property name to get the docstring for
1504
+ The name of the property to inspect.
1426
1505
 
1427
1506
  Returns
1428
1507
  -------
1429
- str
1430
- The docstring of the property
1508
+ str or None
1509
+ The docstring of the property's getter function, or None if not defined.
1431
1510
 
1432
1511
  Raises
1433
1512
  ------
@@ -1450,45 +1529,55 @@ class ReflectionConcrete(IReflectionConcrete):
1450
1529
 
1451
1530
  def getConstructorSignature(self) -> inspect.Signature:
1452
1531
  """
1453
- Get the signature of the constructor of the instance's class.
1532
+ Get the signature of the class constructor.
1454
1533
 
1455
1534
  Returns
1456
1535
  -------
1457
1536
  inspect.Signature
1458
- The signature of the constructor
1537
+ The signature of the __init__ method containing parameter information.
1459
1538
  """
1460
1539
  return inspect.signature(self._concrete.__init__)
1461
1540
 
1462
1541
  def getConstructorDependencies(self) -> ClassDependency:
1463
1542
  """
1464
- Get the resolved and unresolved dependencies from the constructor of the instance's class.
1543
+ Get dependency analysis for the class constructor.
1544
+
1545
+ Analyzes the constructor parameters to identify resolved and unresolved
1546
+ dependencies based on type annotations and default values.
1465
1547
 
1466
1548
  Returns
1467
1549
  -------
1468
1550
  ClassDependency
1469
- A structured representation of the constructor dependencies, containing:
1470
- - resolved: Dictionary of resolved dependencies with their names and values.
1471
- - unresolved: List of unresolved dependencies (parameter names without default values or annotations).
1551
+ A structured representation containing resolved dependencies
1552
+ (with default values/annotations) and unresolved dependencies
1553
+ (parameters without defaults or type information).
1472
1554
  """
1473
1555
  return ReflectDependencies(self._concrete).getConstructorDependencies()
1474
1556
 
1475
1557
  def getMethodDependencies(self, method_name: str) -> MethodDependency:
1476
1558
  """
1477
- Get the resolved and unresolved dependencies from a method of the instance's class.
1559
+ Get dependency analysis for a specific method.
1560
+
1561
+ Analyzes the method parameters to identify resolved and unresolved
1562
+ dependencies, handling private method name mangling automatically.
1478
1563
 
1479
1564
  Parameters
1480
1565
  ----------
1481
1566
  method_name : str
1482
- The name of the method to inspect
1567
+ The name of the method to analyze.
1483
1568
 
1484
1569
  Returns
1485
1570
  -------
1486
1571
  MethodDependency
1487
- A structured representation of the method dependencies, containing:
1488
- - resolved: Dictionary of resolved dependencies with their names and values.
1489
- - unresolved: List of unresolved dependencies (parameter names without default values or annotations).
1490
- """
1572
+ A structured representation containing resolved dependencies
1573
+ (with default values/annotations) and unresolved dependencies
1574
+ (parameters without defaults or type information).
1491
1575
 
1576
+ Raises
1577
+ ------
1578
+ ReflectionAttributeError
1579
+ If the method does not exist in the class.
1580
+ """
1492
1581
  # Ensure the method name is a valid identifier
1493
1582
  if not self.hasMethod(method_name):
1494
1583
  raise ReflectionAttributeError(f"Method '{method_name}' does not exist on '{self.getClassName()}'.")
@@ -1503,12 +1592,20 @@ class ReflectionConcrete(IReflectionConcrete):
1503
1592
 
1504
1593
  def reflectionInstance(self) -> ReflectionInstance:
1505
1594
  """
1506
- Get the reflection instance of the concrete class.
1595
+ Get a reflection wrapper for the current class instance.
1596
+
1597
+ Provides access to instance-level reflection capabilities for the
1598
+ instantiated object.
1507
1599
 
1508
1600
  Returns
1509
1601
  -------
1510
1602
  ReflectionInstance
1511
- An instance of ReflectionInstance for the concrete class
1603
+ A reflection wrapper for instance-level introspection operations.
1604
+
1605
+ Raises
1606
+ ------
1607
+ ReflectionValueError
1608
+ If no instance has been created using getInstance().
1512
1609
  """
1513
1610
  if not self.__instance:
1514
1611
  raise ReflectionValueError(f"Instance of class '{self.getClassName()}' is not initialized. Use getInstance() to create an instance before calling methods.")