orionis 0.297.0__py3-none-any.whl → 0.298.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.
- orionis/metadata/framework.py +1 -1
- orionis/services/introspection/instances/reflection_instance.py +361 -248
- {orionis-0.297.0.dist-info → orionis-0.298.0.dist-info}/METADATA +1 -1
- {orionis-0.297.0.dist-info → orionis-0.298.0.dist-info}/RECORD +9 -11
- tests/support/inspection/fakes/fake_reflect_instance.py +36 -1
- orionis/services/introspection/instances/entities/class_attributes.py +0 -20
- orionis/services/introspection/instances/entities/class_method.py +0 -41
- {orionis-0.297.0.dist-info → orionis-0.298.0.dist-info}/WHEEL +0 -0
- {orionis-0.297.0.dist-info → orionis-0.298.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.297.0.dist-info → orionis-0.298.0.dist-info}/top_level.txt +0 -0
- {orionis-0.297.0.dist-info → orionis-0.298.0.dist-info}/zip-safe +0 -0
orionis/metadata/framework.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import inspect
|
2
|
+
import keyword
|
2
3
|
from typing import Any, Callable, Dict, List, Optional, Tuple, Type
|
3
4
|
from orionis.services.asynchrony.coroutines import Coroutine
|
4
5
|
from orionis.services.introspection.dependencies.entities.class_dependencies import ClassDependency
|
@@ -7,8 +8,6 @@ from orionis.services.introspection.dependencies.reflect_dependencies import Ref
|
|
7
8
|
from orionis.services.introspection.exceptions.reflection_attribute_error import ReflectionAttributeError
|
8
9
|
from orionis.services.introspection.exceptions.reflection_type_error import ReflectionTypeError
|
9
10
|
from orionis.services.introspection.exceptions.reflection_value_error import ReflectionValueError
|
10
|
-
from orionis.services.introspection.instances.entities.class_attributes import ClassAttributes
|
11
|
-
from orionis.services.introspection.instances.entities.class_method import ClassMethod
|
12
11
|
from orionis.services.introspection.instances.entities.class_property import ClassProperty
|
13
12
|
|
14
13
|
class ReflectionInstance:
|
@@ -86,7 +85,163 @@ class ReflectionInstance:
|
|
86
85
|
str
|
87
86
|
The module name
|
88
87
|
"""
|
89
|
-
return f"{self.
|
88
|
+
return f"{self.getModuleName()}.{self.getClassName()}"
|
89
|
+
|
90
|
+
def getDocstring(self) -> Optional[str]:
|
91
|
+
"""
|
92
|
+
Get the docstring of the instance's class.
|
93
|
+
|
94
|
+
Returns
|
95
|
+
-------
|
96
|
+
Optional[str]
|
97
|
+
The class docstring, or None if not available
|
98
|
+
"""
|
99
|
+
return self._instance.__class__.__doc__
|
100
|
+
|
101
|
+
def getBaseClasses(self) -> Tuple[Type, ...]:
|
102
|
+
"""
|
103
|
+
Get the base classes of the instance's class.
|
104
|
+
|
105
|
+
Returns
|
106
|
+
-------
|
107
|
+
Tuple[Type, ...]
|
108
|
+
Tuple of base classes
|
109
|
+
"""
|
110
|
+
return self._instance.__class__.__bases__
|
111
|
+
|
112
|
+
def getSourceCode(self) -> Optional[str]:
|
113
|
+
"""
|
114
|
+
Get the source code of the instance's class.
|
115
|
+
|
116
|
+
Returns
|
117
|
+
-------
|
118
|
+
Optional[str]
|
119
|
+
The source code if available, None otherwise
|
120
|
+
"""
|
121
|
+
try:
|
122
|
+
return inspect.getsource(self._instance.__class__)
|
123
|
+
except (TypeError, OSError):
|
124
|
+
return None
|
125
|
+
|
126
|
+
def getFile(self) -> Optional[str]:
|
127
|
+
"""
|
128
|
+
Get the file location where the class is defined.
|
129
|
+
|
130
|
+
Returns
|
131
|
+
-------
|
132
|
+
Optional[str]
|
133
|
+
The file path if available, None otherwise
|
134
|
+
"""
|
135
|
+
try:
|
136
|
+
return inspect.getfile(self._instance.__class__)
|
137
|
+
except (TypeError, OSError):
|
138
|
+
return None
|
139
|
+
|
140
|
+
def getAnnotations(self) -> Dict[str, Any]:
|
141
|
+
"""
|
142
|
+
Get type annotations of the class.
|
143
|
+
|
144
|
+
Returns
|
145
|
+
-------
|
146
|
+
Dict[str, Any]
|
147
|
+
Dictionary of attribute names and their type annotations
|
148
|
+
"""
|
149
|
+
return self._instance.__class__.__annotations__
|
150
|
+
|
151
|
+
def hasAttribute(self, name: str) -> bool:
|
152
|
+
"""
|
153
|
+
Check if the instance has a specific attribute.
|
154
|
+
|
155
|
+
Parameters
|
156
|
+
----------
|
157
|
+
name : str
|
158
|
+
The attribute name to check
|
159
|
+
|
160
|
+
Returns
|
161
|
+
-------
|
162
|
+
bool
|
163
|
+
True if the attribute exists
|
164
|
+
"""
|
165
|
+
return name in self.getAttributes()
|
166
|
+
|
167
|
+
def getAttribute(self, name: str) -> Any:
|
168
|
+
"""
|
169
|
+
Get an attribute value by name.
|
170
|
+
|
171
|
+
Parameters
|
172
|
+
----------
|
173
|
+
name : str
|
174
|
+
The attribute name
|
175
|
+
|
176
|
+
Returns
|
177
|
+
-------
|
178
|
+
Any
|
179
|
+
The attribute value
|
180
|
+
|
181
|
+
Raises
|
182
|
+
------
|
183
|
+
AttributeError
|
184
|
+
If the attribute doesn't exist
|
185
|
+
"""
|
186
|
+
attrs = self.getAttributes()
|
187
|
+
return attrs.get(name, None)
|
188
|
+
|
189
|
+
def setAttribute(self, name: str, value: Any) -> bool:
|
190
|
+
"""
|
191
|
+
Set an attribute value.
|
192
|
+
|
193
|
+
Parameters
|
194
|
+
----------
|
195
|
+
name : str
|
196
|
+
The attribute name
|
197
|
+
value : Any
|
198
|
+
The value to set
|
199
|
+
|
200
|
+
Raises
|
201
|
+
------
|
202
|
+
ReflectionAttributeError
|
203
|
+
If the attribute is read-only
|
204
|
+
"""
|
205
|
+
# Ensure the name is a valid attr name with regular expression
|
206
|
+
if not isinstance(name, str) or not name.isidentifier() or keyword.iskeyword(name):
|
207
|
+
raise ReflectionAttributeError(f"Invalid method name '{name}'. Must be a valid Python identifier and not a keyword.")
|
208
|
+
|
209
|
+
# Ensure the value is not callable
|
210
|
+
if callable(value):
|
211
|
+
raise ReflectionAttributeError(f"Cannot set attribute '{name}' to a callable. Use setMacro instead.")
|
212
|
+
|
213
|
+
# Handle private attribute name mangling
|
214
|
+
if name.startswith("__") and not name.endswith("__"):
|
215
|
+
class_name = self.getClassName()
|
216
|
+
name = f"_{class_name}{name}"
|
217
|
+
|
218
|
+
# Check if the attribute already exists
|
219
|
+
setattr(self._instance, name, value)
|
220
|
+
|
221
|
+
# Return True
|
222
|
+
return True
|
223
|
+
|
224
|
+
def removeAttribute(self, name: str) -> bool:
|
225
|
+
"""
|
226
|
+
Remove an attribute from the instance.
|
227
|
+
|
228
|
+
Parameters
|
229
|
+
----------
|
230
|
+
name : str
|
231
|
+
The attribute name to remove
|
232
|
+
|
233
|
+
Raises
|
234
|
+
------
|
235
|
+
ReflectionAttributeError
|
236
|
+
If the attribute doesn't exist or is read-only
|
237
|
+
"""
|
238
|
+
if self.getAttribute(name) is None:
|
239
|
+
raise ReflectionAttributeError(f"'{self.getClassName()}' object has no attribute '{name}'.")
|
240
|
+
if name.startswith("__") and not name.endswith("__"):
|
241
|
+
class_name = self.getClassName()
|
242
|
+
name = f"_{class_name}{name}"
|
243
|
+
delattr(self._instance, name)
|
244
|
+
return True
|
90
245
|
|
91
246
|
def getAttributes(self) -> Dict[str, Any]:
|
92
247
|
"""
|
@@ -188,6 +343,187 @@ class ReflectionInstance:
|
|
188
343
|
|
189
344
|
return dunder
|
190
345
|
|
346
|
+
def getMagicAttributes(self) -> Dict[str, Any]:
|
347
|
+
"""
|
348
|
+
Get all magic attributes of the instance.
|
349
|
+
|
350
|
+
Returns
|
351
|
+
-------
|
352
|
+
Dict[str, Any]
|
353
|
+
Dictionary of magic attribute names and their values
|
354
|
+
"""
|
355
|
+
return self.getDunderAttributes()
|
356
|
+
|
357
|
+
def hasMethod(self, name: str) -> bool:
|
358
|
+
"""
|
359
|
+
Check if the instance has a specific method.
|
360
|
+
|
361
|
+
Parameters
|
362
|
+
----------
|
363
|
+
name : str
|
364
|
+
The method name to check
|
365
|
+
|
366
|
+
Returns
|
367
|
+
-------
|
368
|
+
bool
|
369
|
+
True if the method exists, False otherwise
|
370
|
+
"""
|
371
|
+
# Handle private method name mangling
|
372
|
+
if name.startswith("__") and not name.endswith("__"):
|
373
|
+
class_name = self.getClassName()
|
374
|
+
name = f"_{class_name}{name}"
|
375
|
+
|
376
|
+
# Check if the method is callable
|
377
|
+
if hasattr(self._instance, name):
|
378
|
+
return callable(getattr(self._instance, name, None))
|
379
|
+
|
380
|
+
# Check if the method is a class method or static method
|
381
|
+
cls = self._instance.__class__
|
382
|
+
if hasattr(cls, name):
|
383
|
+
attr = inspect.getattr_static(cls, name)
|
384
|
+
return isinstance(attr, (classmethod, staticmethod)) and callable(attr.__func__)
|
385
|
+
|
386
|
+
# If not found, return False
|
387
|
+
return False
|
388
|
+
|
389
|
+
def callMethod(self, name: str, *args: Any, **kwargs: Any) -> Any:
|
390
|
+
"""
|
391
|
+
Call a method on the instance.
|
392
|
+
|
393
|
+
Parameters
|
394
|
+
----------
|
395
|
+
name : str
|
396
|
+
Name of the method to call
|
397
|
+
*args : Any
|
398
|
+
Positional arguments for the method
|
399
|
+
**kwargs : Any
|
400
|
+
Keyword arguments for the method
|
401
|
+
|
402
|
+
Returns
|
403
|
+
-------
|
404
|
+
Any
|
405
|
+
The result of the method call
|
406
|
+
|
407
|
+
Raises
|
408
|
+
------
|
409
|
+
AttributeError
|
410
|
+
If the method does not exist on the instance
|
411
|
+
TypeError
|
412
|
+
If the method is not callable
|
413
|
+
"""
|
414
|
+
|
415
|
+
# Hanlde private method name mangling
|
416
|
+
if name.startswith("__") and not name.endswith("__"):
|
417
|
+
class_name = self.getClassName()
|
418
|
+
name = f"_{class_name}{name}"
|
419
|
+
|
420
|
+
# Try to get the method from the instance
|
421
|
+
method = getattr(self._instance, name, None)
|
422
|
+
|
423
|
+
# If not found, try to get it from the class
|
424
|
+
if method is None:
|
425
|
+
cls = self._instance.__class__
|
426
|
+
method = getattr(cls, name, None)
|
427
|
+
|
428
|
+
# If still not found, raise an error
|
429
|
+
if method is None:
|
430
|
+
raise ReflectionAttributeError(f"Method '{name}' does not exist on '{self.getClassName()}'.")
|
431
|
+
|
432
|
+
# Check if the method is callable
|
433
|
+
if not callable(method):
|
434
|
+
raise ReflectionTypeError(f"'{name}' is not callable on '{self.getClassName()}'.")
|
435
|
+
|
436
|
+
# Check if method is coroutine function
|
437
|
+
if inspect.iscoroutinefunction(method):
|
438
|
+
return Coroutine(method(*args, **kwargs)).run()
|
439
|
+
|
440
|
+
# Call the method with provided arguments
|
441
|
+
return method(*args, **kwargs)
|
442
|
+
|
443
|
+
def setMethod(self, name: str, value: Callable) -> bool:
|
444
|
+
"""
|
445
|
+
Set a callable attribute value.
|
446
|
+
|
447
|
+
Parameters
|
448
|
+
----------
|
449
|
+
name : str
|
450
|
+
The attribute name
|
451
|
+
value : Callable
|
452
|
+
The callable to set
|
453
|
+
|
454
|
+
Raises
|
455
|
+
------
|
456
|
+
ReflectionAttributeError
|
457
|
+
If the attribute is not callable or already exists as a method
|
458
|
+
"""
|
459
|
+
# Ensure the name is a valid method name with regular expression
|
460
|
+
if not isinstance(name, str) or not name.isidentifier() or keyword.iskeyword(name):
|
461
|
+
raise ReflectionAttributeError(f"Invalid method name '{name}'. Must be a valid Python identifier and not a keyword.")
|
462
|
+
|
463
|
+
# Ensure the value is callable
|
464
|
+
if not callable(value):
|
465
|
+
raise ReflectionAttributeError(f"Cannot set attribute '{name}' to a non-callable value.")
|
466
|
+
|
467
|
+
# Handle private method name mangling
|
468
|
+
if name.startswith("__") and not name.endswith("__"):
|
469
|
+
class_name = self.getClassName()
|
470
|
+
name = f"_{class_name}{name}"
|
471
|
+
|
472
|
+
# Check if the method already exists
|
473
|
+
if hasattr(self._instance, name):
|
474
|
+
raise ReflectionAttributeError(f"Attribute '{name}' already exists on '{self.getClassName()}'.")
|
475
|
+
|
476
|
+
# Set the method on the instance
|
477
|
+
setattr(self._instance, name, value)
|
478
|
+
|
479
|
+
# Return True
|
480
|
+
return True
|
481
|
+
|
482
|
+
def removeMethod(self, name: str) -> None:
|
483
|
+
"""
|
484
|
+
Remove a method from the instance.
|
485
|
+
|
486
|
+
Parameters
|
487
|
+
----------
|
488
|
+
name : str
|
489
|
+
The method name to remove
|
490
|
+
|
491
|
+
Raises
|
492
|
+
------
|
493
|
+
ReflectionAttributeError
|
494
|
+
If the method does not exist or is not callable
|
495
|
+
"""
|
496
|
+
if not self.hasMethod(name):
|
497
|
+
raise ReflectionAttributeError(f"Method '{name}' does not exist on '{self.getClassName()}'.")
|
498
|
+
delattr(self._instance, name)
|
499
|
+
|
500
|
+
def getMethodSignature(self, name: str) -> inspect.Signature:
|
501
|
+
"""
|
502
|
+
Get the signature of a method.
|
503
|
+
|
504
|
+
Parameters
|
505
|
+
----------
|
506
|
+
name : str
|
507
|
+
Name of the method
|
508
|
+
|
509
|
+
Returns
|
510
|
+
-------
|
511
|
+
inspect.Signature
|
512
|
+
The method signature
|
513
|
+
"""
|
514
|
+
|
515
|
+
# Handle private method name mangling
|
516
|
+
if name.startswith("__") and not name.endswith("__"):
|
517
|
+
name = f"_{self.getClassName()}{name}"
|
518
|
+
|
519
|
+
# Check if the method exists and is callable
|
520
|
+
method = getattr(self._instance, name)
|
521
|
+
if callable(method):
|
522
|
+
return inspect.signature(method)
|
523
|
+
|
524
|
+
# If the method is not callable, raise an error
|
525
|
+
raise ReflectionAttributeError(f"Method '{name}' is not callable on '{self.getClassName()}'.")
|
526
|
+
|
191
527
|
def getPublicMethods(self) -> List[str]:
|
192
528
|
"""
|
193
529
|
Get all public method names of the instance.
|
@@ -344,6 +680,20 @@ class ReflectionInstance:
|
|
344
680
|
private_methods.append(short_name)
|
345
681
|
return private_methods
|
346
682
|
|
683
|
+
|
684
|
+
|
685
|
+
|
686
|
+
|
687
|
+
|
688
|
+
|
689
|
+
|
690
|
+
|
691
|
+
|
692
|
+
|
693
|
+
|
694
|
+
|
695
|
+
|
696
|
+
|
347
697
|
def getPublicClassMethods(self) -> List[str]:
|
348
698
|
"""
|
349
699
|
Get all class method names of the instance.
|
@@ -1038,263 +1388,26 @@ class ReflectionInstance:
|
|
1038
1388
|
|
1039
1389
|
|
1040
1390
|
|
1041
|
-
|
1042
|
-
"""
|
1043
|
-
Call a method on the instance.
|
1044
|
-
|
1045
|
-
Parameters
|
1046
|
-
----------
|
1047
|
-
method_name : str
|
1048
|
-
Name of the method to call
|
1049
|
-
*args : Any
|
1050
|
-
Positional arguments for the method
|
1051
|
-
**kwargs : Any
|
1052
|
-
Keyword arguments for the method
|
1053
|
-
|
1054
|
-
Returns
|
1055
|
-
-------
|
1056
|
-
Any
|
1057
|
-
The result of the method call
|
1058
|
-
|
1059
|
-
Raises
|
1060
|
-
------
|
1061
|
-
AttributeError
|
1062
|
-
If the method does not exist on the instance
|
1063
|
-
TypeError
|
1064
|
-
If the method is not callable
|
1065
|
-
"""
|
1066
|
-
|
1067
|
-
if method_name in self.getPrivateMethods():
|
1068
|
-
method_name = f"_{self.getClassName()}{method_name}"
|
1069
|
-
|
1070
|
-
method = getattr(self._instance, method_name, None)
|
1071
|
-
|
1072
|
-
if method is None:
|
1073
|
-
raise AttributeError(f"'{self.getClassName()}' object has no method '{method_name}'.")
|
1074
|
-
if not callable(method):
|
1075
|
-
raise TypeError(f"'{method_name}' is not callable on '{self.getClassName()}'.")
|
1076
|
-
|
1077
|
-
if inspect.iscoroutinefunction(method):
|
1078
|
-
return Coroutine(method(*args, **kwargs)).run()
|
1079
|
-
|
1080
|
-
return method(*args, **kwargs)
|
1081
|
-
|
1082
|
-
def getMethodSignature(self, method_name: str) -> inspect.Signature:
|
1083
|
-
"""
|
1084
|
-
Get the signature of a method.
|
1085
|
-
|
1086
|
-
Parameters
|
1087
|
-
----------
|
1088
|
-
method_name : str
|
1089
|
-
Name of the method
|
1090
|
-
|
1091
|
-
Returns
|
1092
|
-
-------
|
1093
|
-
inspect.Signature
|
1094
|
-
The method signature
|
1095
|
-
"""
|
1096
|
-
if method_name in self.getPrivateMethods():
|
1097
|
-
method_name = f"_{self.getClassName()}{method_name}"
|
1098
|
-
|
1099
|
-
method = getattr(self._instance, method_name)
|
1100
|
-
if callable(method):
|
1101
|
-
return inspect.signature(method)
|
1102
|
-
|
1103
|
-
def getDocstring(self) -> Optional[str]:
|
1104
|
-
"""
|
1105
|
-
Get the docstring of the instance's class.
|
1106
|
-
|
1107
|
-
Returns
|
1108
|
-
-------
|
1109
|
-
Optional[str]
|
1110
|
-
The class docstring, or None if not available
|
1111
|
-
"""
|
1112
|
-
return self._instance.__class__.__doc__
|
1113
|
-
|
1114
|
-
def getBaseClasses(self) -> Tuple[Type, ...]:
|
1115
|
-
"""
|
1116
|
-
Get the base classes of the instance's class.
|
1117
|
-
|
1118
|
-
Returns
|
1119
|
-
-------
|
1120
|
-
Tuple[Type, ...]
|
1121
|
-
Tuple of base classes
|
1122
|
-
"""
|
1123
|
-
return self._instance.__class__.__bases__
|
1124
|
-
|
1125
|
-
def isInstanceOf(self, cls: Type) -> bool:
|
1126
|
-
"""
|
1127
|
-
Check if the instance is of a specific class.
|
1128
|
-
|
1129
|
-
Parameters
|
1130
|
-
----------
|
1131
|
-
cls : Type
|
1132
|
-
The class to check against
|
1133
|
-
|
1134
|
-
Returns
|
1135
|
-
-------
|
1136
|
-
bool
|
1137
|
-
True if the instance is of the specified class
|
1138
|
-
"""
|
1139
|
-
return isinstance(self._instance, cls)
|
1140
|
-
|
1141
|
-
def getSourceCode(self) -> Optional[str]:
|
1142
|
-
"""
|
1143
|
-
Get the source code of the instance's class.
|
1144
|
-
|
1145
|
-
Returns
|
1146
|
-
-------
|
1147
|
-
Optional[str]
|
1148
|
-
The source code if available, None otherwise
|
1149
|
-
"""
|
1150
|
-
try:
|
1151
|
-
return inspect.getsource(self._instance.__class__)
|
1152
|
-
except (TypeError, OSError):
|
1153
|
-
return None
|
1154
|
-
|
1155
|
-
def getFileLocation(self) -> Optional[str]:
|
1156
|
-
"""
|
1157
|
-
Get the file location where the class is defined.
|
1158
|
-
|
1159
|
-
Returns
|
1160
|
-
-------
|
1161
|
-
Optional[str]
|
1162
|
-
The file path if available, None otherwise
|
1163
|
-
"""
|
1164
|
-
try:
|
1165
|
-
return inspect.getfile(self._instance.__class__)
|
1166
|
-
except (TypeError, OSError):
|
1167
|
-
return None
|
1168
|
-
|
1169
|
-
def getAnnotations(self) -> Dict[str, Any]:
|
1170
|
-
"""
|
1171
|
-
Get type annotations of the class.
|
1172
|
-
|
1173
|
-
Returns
|
1174
|
-
-------
|
1175
|
-
Dict[str, Any]
|
1176
|
-
Dictionary of attribute names and their type annotations
|
1177
|
-
"""
|
1178
|
-
return self._instance.__class__.__annotations__
|
1179
|
-
|
1180
|
-
def hasAttribute(self, name: str) -> bool:
|
1181
|
-
"""
|
1182
|
-
Check if the instance has a specific attribute.
|
1183
|
-
|
1184
|
-
Parameters
|
1185
|
-
----------
|
1186
|
-
name : str
|
1187
|
-
The attribute name to check
|
1188
|
-
|
1189
|
-
Returns
|
1190
|
-
-------
|
1191
|
-
bool
|
1192
|
-
True if the attribute exists
|
1193
|
-
"""
|
1194
|
-
return hasattr(self._instance, name)
|
1195
|
-
|
1196
|
-
def getAttribute(self, name: str) -> Any:
|
1197
|
-
"""
|
1198
|
-
Get an attribute value by name.
|
1199
|
-
|
1200
|
-
Parameters
|
1201
|
-
----------
|
1202
|
-
name : str
|
1203
|
-
The attribute name
|
1204
|
-
|
1205
|
-
Returns
|
1206
|
-
-------
|
1207
|
-
Any
|
1208
|
-
The attribute value
|
1209
|
-
|
1210
|
-
Raises
|
1211
|
-
------
|
1212
|
-
AttributeError
|
1213
|
-
If the attribute doesn't exist
|
1214
|
-
"""
|
1215
|
-
attrs = self.getAttributes()
|
1216
|
-
return attrs.get(name, getattr(self._instance, name, None))
|
1217
|
-
|
1218
|
-
def setAttribute(self, name: str, value: Any) -> None:
|
1219
|
-
"""
|
1220
|
-
Set an attribute value.
|
1221
|
-
|
1222
|
-
Parameters
|
1223
|
-
----------
|
1224
|
-
name : str
|
1225
|
-
The attribute name
|
1226
|
-
value : Any
|
1227
|
-
The value to set
|
1228
|
-
|
1229
|
-
Raises
|
1230
|
-
------
|
1231
|
-
AttributeError
|
1232
|
-
If the attribute is read-only
|
1233
|
-
"""
|
1234
|
-
if callable(value):
|
1235
|
-
raise AttributeError(f"Cannot set attribute '{name}' to a callable. Use setMacro instead.")
|
1236
|
-
setattr(self._instance, name, value)
|
1237
|
-
|
1238
|
-
def removeAttribute(self, name: str) -> None:
|
1239
|
-
"""
|
1240
|
-
Remove an attribute from the instance.
|
1241
|
-
|
1242
|
-
Parameters
|
1243
|
-
----------
|
1244
|
-
name : str
|
1245
|
-
The attribute name to remove
|
1391
|
+
|
1246
1392
|
|
1247
|
-
|
1248
|
-
------
|
1249
|
-
AttributeError
|
1250
|
-
If the attribute doesn't exist or is read-only
|
1251
|
-
"""
|
1252
|
-
if not hasattr(self._instance, name):
|
1253
|
-
raise AttributeError(f"'{self.getClassName()}' object has no attribute '{name}'.")
|
1254
|
-
delattr(self._instance, name)
|
1393
|
+
|
1255
1394
|
|
1256
|
-
|
1257
|
-
"""
|
1258
|
-
Set a callable attribute value.
|
1395
|
+
|
1259
1396
|
|
1260
|
-
|
1261
|
-
----------
|
1262
|
-
name : str
|
1263
|
-
The attribute name
|
1264
|
-
value : Callable
|
1265
|
-
The callable to set
|
1397
|
+
|
1266
1398
|
|
1267
|
-
Raises
|
1268
|
-
------
|
1269
|
-
AttributeError
|
1270
|
-
If the value is not callable
|
1271
|
-
"""
|
1272
|
-
if not callable(value):
|
1273
|
-
raise AttributeError(f"The value for '{name}' must be a callable.")
|
1274
|
-
setattr(self._instance, name, value)
|
1275
1399
|
|
1276
|
-
|
1277
|
-
"""
|
1278
|
-
Remove a callable attribute from the instance.
|
1400
|
+
|
1279
1401
|
|
1280
|
-
|
1281
|
-
----------
|
1282
|
-
name : str
|
1283
|
-
The attribute name to remove
|
1402
|
+
|
1284
1403
|
|
1285
|
-
Raises
|
1286
|
-
------
|
1287
|
-
AttributeError
|
1288
|
-
If the attribute doesn't exist or is not callable
|
1289
|
-
"""
|
1290
|
-
if not hasattr(self._instance, name) or not callable(getattr(self._instance, name)):
|
1291
|
-
raise AttributeError(f"'{self.getClassName()}' object has no callable macro '{name}'.")
|
1292
|
-
delattr(self._instance, name)
|
1293
1404
|
|
1294
1405
|
def getConstructorDependencies(self) -> ClassDependency:
|
1295
1406
|
"""
|
1296
1407
|
Get the resolved and unresolved dependencies from the constructor of the instance's class.
|
1297
1408
|
|
1409
|
+
|
1410
|
+
|
1298
1411
|
Returns
|
1299
1412
|
-------
|
1300
1413
|
ClassDependency
|
@@ -226,7 +226,7 @@ orionis/foundation/config/testing/entities/testing.py,sha256=AuhPU9O15Aeqs8jQVHW
|
|
226
226
|
orionis/foundation/config/testing/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
227
227
|
orionis/foundation/config/testing/enums/test_mode.py,sha256=IbFpauu7J-iSAfmC8jDbmTEYl8eZr-AexL-lyOh8_74,337
|
228
228
|
orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
229
|
-
orionis/metadata/framework.py,sha256=
|
229
|
+
orionis/metadata/framework.py,sha256=4H5rxpA-HVckOuD2k5RCAOQ0Y0PbT1SFH_FFHF41i4I,4960
|
230
230
|
orionis/metadata/package.py,sha256=tqLfBRo-w1j_GN4xvzUNFyweWYFS-qhSgAEc-AmCH1M,5452
|
231
231
|
orionis/patterns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
232
232
|
orionis/patterns/singleton/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -262,10 +262,8 @@ orionis/services/introspection/exceptions/reflection_attribute_error.py,sha256=7
|
|
262
262
|
orionis/services/introspection/exceptions/reflection_type_error.py,sha256=6BizQOgt50qlLPDBvBJfUWgAwAr_8GAk1FhownPs-8A,747
|
263
263
|
orionis/services/introspection/exceptions/reflection_value_error.py,sha256=X38649JMKSPbdpa1lmo69RhhTATH8ykTF-UAqe7IAaU,748
|
264
264
|
orionis/services/introspection/instances/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
265
|
-
orionis/services/introspection/instances/reflection_instance.py,sha256=
|
265
|
+
orionis/services/introspection/instances/reflection_instance.py,sha256=FyhobfRgP-9CBW61Yl-GyASca-oLsMldDsvF3zGY90Y,40981
|
266
266
|
orionis/services/introspection/instances/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
267
|
-
orionis/services/introspection/instances/entities/class_attributes.py,sha256=zY8VDZk3Fa6kVj4VC5zGDhwA4iFe0OzB5nxGbWFgTLA,577
|
268
|
-
orionis/services/introspection/instances/entities/class_method.py,sha256=yvFSDR04Ga-9thoPrNM0lgPu7nfUSdDuw9aQtgnQN90,1201
|
269
267
|
orionis/services/introspection/instances/entities/class_property.py,sha256=QwXmCnyPpmORELuTU2VH85nO_1rKMQFvhPKUP6tMCSU,631
|
270
268
|
orionis/services/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
271
269
|
orionis/services/parsers/serializer.py,sha256=mxWlzqgkoO7EeIr3MZ5gdzQUuSfjqWDMau85PEqlBQY,531
|
@@ -355,7 +353,7 @@ orionis/test/suites/contracts/test_suite.py,sha256=eluzYwkNBbKjxYStj_tHN_Fm3YDPp
|
|
355
353
|
orionis/test/suites/contracts/test_unit.py,sha256=l1LQllODyvcSByXMl1lGrUkoLsXbBHZZLWZI4A-mlQg,5881
|
356
354
|
orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
357
355
|
orionis/test/view/render.py,sha256=jXZkbITBknbUwm_mD8bcTiwLDvsFkrO9qrf0ZgPwqxc,4903
|
358
|
-
orionis-0.
|
356
|
+
orionis-0.298.0.dist-info/licenses/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
|
359
357
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
360
358
|
tests/example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
361
359
|
tests/example/test_example.py,sha256=byd_lI6tVDgGPEIrr7PLZbBu0UoZOymmdmyA_4u-QUw,601
|
@@ -452,15 +450,15 @@ tests/support/inspection/test_reflection_concrete_with_abstract.py,sha256=Qzd87J
|
|
452
450
|
tests/support/inspection/test_reflection_instance_with_abstract.py,sha256=L3nQy2l95yEIyvAHErqxGRVVF5x8YkyM82uGm0wUlxk,4064
|
453
451
|
tests/support/inspection/fakes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
454
452
|
tests/support/inspection/fakes/fake_reflect_abstract.py,sha256=woE15uLmoD3fLgPBMjNh5XkwvMDmW2VDbADYPIS_88o,6387
|
455
|
-
tests/support/inspection/fakes/fake_reflect_instance.py,sha256=
|
453
|
+
tests/support/inspection/fakes/fake_reflect_instance.py,sha256=yIruuGGx5asgBPD6JSSwjdAOaMM5soyYZM1JyBjfcFk,3975
|
456
454
|
tests/support/inspection/fakes/fake_reflection_concrete.py,sha256=j6gzsxE3xq5oJ30H_Hm1RsUwEY3jOYBu4sclxtD1ayo,1047
|
457
455
|
tests/support/inspection/fakes/fake_reflection_concrete_with_abstract.py,sha256=ibCjrtNM6BMf5Z5VMvat7E6zOAk5g9z--gj4ykKJWY8,2118
|
458
456
|
tests/support/inspection/fakes/fake_reflection_instance_with_abstract.py,sha256=SfL8FuFmr650RlzXTrP4tGMfsPVZLhOxVnBXu_g1POg,1471
|
459
457
|
tests/testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
460
458
|
tests/testing/test_testing_result.py,sha256=MrGK3ZimedL0b5Ydu69Dg8Iul017AzLTm7VPxpXlpfU,4315
|
461
459
|
tests/testing/test_testing_unit.py,sha256=A6QkiOkP7GPC1Szh_GqsrV7GxjWjK8cIwFez6YfrzmM,7683
|
462
|
-
orionis-0.
|
463
|
-
orionis-0.
|
464
|
-
orionis-0.
|
465
|
-
orionis-0.
|
466
|
-
orionis-0.
|
460
|
+
orionis-0.298.0.dist-info/METADATA,sha256=uWwfTJ0inS9aR2MHSZLnoOEAvTtrmF1b89aVMt9vNyo,4772
|
461
|
+
orionis-0.298.0.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
462
|
+
orionis-0.298.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
|
463
|
+
orionis-0.298.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
464
|
+
orionis-0.298.0.dist-info/RECORD,,
|
@@ -4,7 +4,42 @@ class BaseFakeClass:
|
|
4
4
|
pass
|
5
5
|
|
6
6
|
class FakeClass(BaseFakeClass):
|
7
|
-
"""
|
7
|
+
"""
|
8
|
+
FakeClass is a test double for inspection and reflection scenarios.
|
9
|
+
Attributes:
|
10
|
+
class_attr (str): A class-level attribute with a default value "class_value".
|
11
|
+
Instance Attributes:
|
12
|
+
public_attr (int): A public instance attribute initialized to 42.
|
13
|
+
_protected_attr (str): A protected instance attribute initialized to "protected".
|
14
|
+
__private_attr (str): A private instance attribute initialized to "private".
|
15
|
+
dynamic_attr: An instance attribute initialized to None.
|
16
|
+
__dd__ (str): A dunder-named attribute initialized to "dunder_value".
|
17
|
+
Methods:
|
18
|
+
instanceMethod(x: int, y: int) -> int:
|
19
|
+
Adds two numbers and returns the result.
|
20
|
+
computed_property -> str:
|
21
|
+
A computed property that returns a string based on public_attr.
|
22
|
+
classMethod() -> str:
|
23
|
+
Class method returning a string representation of the class attribute.
|
24
|
+
_classMethodProte() -> str:
|
25
|
+
Protected class method returning a string representation of the class attribute.
|
26
|
+
__classMethodPP() -> str:
|
27
|
+
Private class method returning a string representation of the class attribute.
|
28
|
+
staticMethod(text: str) -> str:
|
29
|
+
Static method that returns the uppercase version of the input text.
|
30
|
+
__staticMethodPP(text: str) -> str:
|
31
|
+
Private static method that returns the uppercase version of the input text.
|
32
|
+
staticAsyncMethod(text: str) -> Awaitable[str]:
|
33
|
+
Asynchronous static method that returns the uppercase version of the input text after a delay.
|
34
|
+
__privateMethod() -> str:
|
35
|
+
Private instance method returning a string indicating it is private.
|
36
|
+
_protectedMethod() -> str:
|
37
|
+
Protected instance method returning a string indicating it is protected.
|
38
|
+
asyncMethod() -> Awaitable[str]:
|
39
|
+
Asynchronous instance method returning a string indicating it is async.
|
40
|
+
__str__() -> Awaitable[str]:
|
41
|
+
Asynchronous string representation of the instance.
|
42
|
+
"""
|
8
43
|
|
9
44
|
class_attr: str = "class_value"
|
10
45
|
|
@@ -1,20 +0,0 @@
|
|
1
|
-
from dataclasses import dataclass
|
2
|
-
from typing import Any, Dict
|
3
|
-
|
4
|
-
@dataclass(frozen=True, kw_only=True)
|
5
|
-
class ClassAttributes:
|
6
|
-
"""
|
7
|
-
Represents the attributes of a class instance.
|
8
|
-
|
9
|
-
Parameters
|
10
|
-
----------
|
11
|
-
public : dict of str to Any
|
12
|
-
Public attributes of the class instance.
|
13
|
-
private : dict of str to Any
|
14
|
-
Private attributes of the class instance.
|
15
|
-
protected : dict of str to Any
|
16
|
-
Protected attributes of the class instance.
|
17
|
-
"""
|
18
|
-
public: Dict[str, Any]
|
19
|
-
private: Dict[str, Any]
|
20
|
-
protected: Dict[str, Any]
|
@@ -1,41 +0,0 @@
|
|
1
|
-
from dataclasses import dataclass
|
2
|
-
from typing import List
|
3
|
-
|
4
|
-
@dataclass(frozen=False, kw_only=True)
|
5
|
-
class ClassMethod:
|
6
|
-
"""
|
7
|
-
Represents the methods of a class instance.
|
8
|
-
|
9
|
-
Attributes
|
10
|
-
----------
|
11
|
-
public : List[str]
|
12
|
-
List of public method names.
|
13
|
-
private : List[str]
|
14
|
-
List of private method names.
|
15
|
-
protected : List[str]
|
16
|
-
List of protected method names.
|
17
|
-
static : List[str]
|
18
|
-
List of static method names.
|
19
|
-
asynchronous : List[str]
|
20
|
-
List of asynchronous method names.
|
21
|
-
synchronous : List[str]
|
22
|
-
List of synchronous method names.
|
23
|
-
class_methods : List[str]
|
24
|
-
List of class method names.
|
25
|
-
asynchronous_static : List[str]
|
26
|
-
List of asynchronous static method names.
|
27
|
-
synchronous_static : List[str]
|
28
|
-
List of synchronous static method names.
|
29
|
-
magic : List[str]
|
30
|
-
List of magic method names.
|
31
|
-
"""
|
32
|
-
public: List[str]
|
33
|
-
private: List[str]
|
34
|
-
protected: List[str]
|
35
|
-
static: List[str]
|
36
|
-
asynchronous: List[str]
|
37
|
-
synchronous: List[str]
|
38
|
-
class_methods: List[str]
|
39
|
-
asynchronous_static: List[str]
|
40
|
-
synchronous_static: List[str]
|
41
|
-
magic: List[str]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|