orionis 0.295.0__py3-none-any.whl → 0.297.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 (35) hide show
  1. orionis/metadata/framework.py +1 -1
  2. orionis/services/introspection/dependencies/contracts/reflect_dependencies.py +19 -13
  3. orionis/services/introspection/dependencies/entities/class_dependencies.py +24 -12
  4. orionis/services/introspection/dependencies/entities/method_dependencies.py +26 -13
  5. orionis/services/introspection/dependencies/entities/resolved_dependencies.py +31 -18
  6. orionis/services/introspection/dependencies/reflect_dependencies.py +5 -4
  7. orionis/services/introspection/exceptions/reflection_attribute_error.py +26 -0
  8. orionis/services/introspection/exceptions/reflection_type_error.py +26 -0
  9. orionis/services/introspection/exceptions/reflection_value_error.py +26 -0
  10. orionis/services/introspection/instances/entities/class_attributes.py +20 -0
  11. orionis/services/introspection/instances/entities/class_method.py +41 -0
  12. orionis/services/introspection/instances/entities/class_property.py +24 -0
  13. orionis/services/introspection/instances/reflection_instance.py +1323 -0
  14. orionis/support/helpers/__init__.py +0 -0
  15. orionis/support/introspection/instances/contracts/reflection_instance.py +1 -1
  16. orionis/support/introspection/instances/reflection_instance.py +1 -1
  17. {orionis-0.295.0.dist-info → orionis-0.297.0.dist-info}/METADATA +1 -1
  18. {orionis-0.295.0.dist-info → orionis-0.297.0.dist-info}/RECORD +31 -27
  19. tests/support/inspection/fakes/fake_reflect_instance.py +20 -1
  20. orionis/support/introspection/instances/entities/class_attributes.py +0 -11
  21. orionis/support/introspection/instances/entities/class_method.py +0 -18
  22. orionis/support/introspection/instances/entities/class_parsed.py +0 -18
  23. orionis/support/introspection/instances/entities/class_property.py +0 -13
  24. /orionis/services/introspection/{abstracts → instances}/__init__.py +0 -0
  25. /orionis/services/introspection/{abstracts → instances}/entities/__init__.py +0 -0
  26. /orionis/{services/introspection/helpers → support/abstracts}/__init__.py +0 -0
  27. /orionis/{services/introspection/exceptions/types.py → support/abstracts/entities/__init__.py} +0 -0
  28. /orionis/{services/introspection → support}/abstracts/entities/abstract_class_attributes.py +0 -0
  29. /orionis/{services/introspection → support}/abstracts/reflect_abstract.py +0 -0
  30. /orionis/{services/introspection → support}/helpers/functions.py +0 -0
  31. /orionis/{services/introspection → support}/reflection.py +0 -0
  32. {orionis-0.295.0.dist-info → orionis-0.297.0.dist-info}/WHEEL +0 -0
  33. {orionis-0.295.0.dist-info → orionis-0.297.0.dist-info}/licenses/LICENCE +0 -0
  34. {orionis-0.295.0.dist-info → orionis-0.297.0.dist-info}/top_level.txt +0 -0
  35. {orionis-0.295.0.dist-info → orionis-0.297.0.dist-info}/zip-safe +0 -0
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.295.0"
8
+ VERSION = "0.297.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
@@ -4,40 +4,46 @@ from orionis.services.introspection.dependencies.entities.method_dependencies im
4
4
 
5
5
  class IReflectDependencies(ABC):
6
6
  """
7
- This class is used to reflect dependencies of a given object.
8
- """
7
+ Interface for reflecting dependencies of a given object.
9
8
 
10
- def __init__(self, obj):
11
- self.__obj = obj
9
+ This interface provides methods to retrieve both resolved and unresolved
10
+ dependencies from the constructor and methods of a class.
11
+ """
12
12
 
13
13
  @abstractmethod
14
14
  def getConstructorDependencies(self) -> ClassDependency:
15
15
  """
16
- Get the resolved and unresolved dependencies from the constructor of the instance's class.
16
+ Retrieve dependencies from the constructor of the instance's class.
17
17
 
18
18
  Returns
19
19
  -------
20
20
  ClassDependency
21
- A structured representation of the constructor dependencies, containing:
22
- - resolved: Dictionary of resolved dependencies with their names and values.
23
- - unresolved: List of unresolved dependencies (parameter names without default values or annotations).
21
+ Structured representation of the constructor dependencies.
22
+
23
+ - resolved : dict
24
+ Dictionary of resolved dependencies with their names and values.
25
+ - unresolved : list
26
+ List of unresolved dependencies (parameter names without default values or annotations).
24
27
  """
25
28
  pass
26
29
 
27
30
  def getMethodDependencies(self, method_name: str) -> MethodDependency:
28
31
  """
29
- Get the resolved and unresolved dependencies from a method of the instance's class.
32
+ Retrieve dependencies from a method of the instance's class.
30
33
 
31
34
  Parameters
32
35
  ----------
33
36
  method_name : str
34
- The name of the method to inspect
37
+ Name of the method to inspect.
35
38
 
36
39
  Returns
37
40
  -------
38
41
  MethodDependency
39
- A structured representation of the method dependencies, containing:
40
- - resolved: Dictionary of resolved dependencies with their names and values.
41
- - unresolved: List of unresolved dependencies (parameter names without default values or annotations).
42
+ Structured representation of the method dependencies.
43
+
44
+ - resolved : dict
45
+ Dictionary of resolved dependencies with their names and values.
46
+ - unresolved : list
47
+ List of unresolved dependencies (parameter names without default values or annotations).
42
48
  """
43
49
  pass
@@ -1,19 +1,28 @@
1
1
  from dataclasses import dataclass
2
2
  from typing import Any, Dict, List
3
3
  from orionis.services.introspection.dependencies.entities.resolved_dependencies import ResolvedDependency
4
+ from orionis.services.introspection.exceptions.reflection_type_error import ReflectionTypeError
4
5
 
5
6
  @dataclass(frozen=True, kw_only=True)
6
7
  class ClassDependency:
7
8
  """
8
9
  Represents the dependencies of a class, separating resolved and unresolved dependencies.
9
10
 
10
- Attributes:
11
- resolved (Dict[ResolvedDependency, Any]):
12
- A dictionary mapping resolved dependency descriptors to their corresponding resolved instances or values.
13
- All keys must be ResolvedDependency instances.
14
- unresolved (List[str]):
15
- A list of dependency names or identifiers that could not be resolved.
16
- Must contain only strings.
11
+ Parameters
12
+ ----------
13
+ resolved : Dict[ResolvedDependency, Any]
14
+ A dictionary mapping resolved dependency descriptors to their corresponding resolved instances or values.
15
+ All keys must be ResolvedDependency instances.
16
+ unresolved : List[str]
17
+ A list of dependency names or identifiers that could not be resolved.
18
+ Must contain only strings.
19
+
20
+ Attributes
21
+ ----------
22
+ resolved : Dict[ResolvedDependency, Any]
23
+ Dictionary of resolved dependencies.
24
+ unresolved : List[str]
25
+ List of unresolved dependency names.
17
26
  """
18
27
  resolved: Dict[ResolvedDependency, Any]
19
28
  unresolved: List[str]
@@ -22,20 +31,23 @@ class ClassDependency:
22
31
  """
23
32
  Validates types of attributes during initialization.
24
33
 
25
- Raises:
26
- TypeError: If types don't match the expected:
34
+ Raises
35
+ ------
36
+ ReflectionTypeError
37
+ If types don't match the expected:
27
38
  - resolved: Dict[ResolvedDependency, Any]
28
39
  - unresolved: List[str]
29
- ValueError: If resolved contains None keys or unresolved contains empty strings
40
+ ValueError
41
+ If resolved contains None keys or unresolved contains empty strings.
30
42
  """
31
43
  # Validate 'resolved' is a dict with ResolvedDependency keys
32
44
  if not isinstance(self.resolved, dict):
33
- raise TypeError(
45
+ raise ReflectionTypeError(
34
46
  f"'resolved' must be a dict, got {type(self.resolved).__name__}"
35
47
  )
36
48
 
37
49
  # Validate 'unresolved' is a list of non-empty strings
38
50
  if not isinstance(self.unresolved, list):
39
- raise TypeError(
51
+ raise ReflectionTypeError(
40
52
  f"'unresolved' must be a list, got {type(self.unresolved).__name__}"
41
53
  )
@@ -1,20 +1,30 @@
1
1
  from dataclasses import dataclass
2
2
  from typing import Any, Dict, List
3
3
  from orionis.services.introspection.dependencies.entities.resolved_dependencies import ResolvedDependency
4
+ from orionis.services.introspection.exceptions.reflection_type_error import ReflectionTypeError
4
5
 
5
6
  @dataclass(frozen=True, kw_only=True)
6
7
  class MethodDependency:
7
8
  """
8
9
  Represents the dependencies of a method, separating resolved and unresolved dependencies.
9
10
 
10
- Attributes:
11
- resolved (Dict[ResolvedDependency, Any]):
12
- A dictionary mapping resolved dependency descriptors to their corresponding
13
- resolved instances or values for the method.
14
- All keys must be ResolvedDependency instances.
15
- unresolved (List[str]):
16
- A list of method parameter names or dependency identifiers that could not be resolved.
17
- Must contain only non-empty strings.
11
+ Parameters
12
+ ----------
13
+ resolved : Dict[ResolvedDependency, Any]
14
+ A dictionary mapping resolved dependency descriptors to their corresponding
15
+ resolved instances or values for the method. All keys must be ResolvedDependency instances.
16
+ unresolved : List[str]
17
+ A list of method parameter names or dependency identifiers that could not be resolved.
18
+ Must contain only non-empty strings.
19
+
20
+ Raises
21
+ ------
22
+ ReflectionTypeError
23
+ If types don't match the expected:
24
+ - resolved: Dict[ResolvedDependency, Any]
25
+ - unresolved: List[str]
26
+ ValueError
27
+ If resolved contains None keys or unresolved contains empty strings
18
28
  """
19
29
  resolved: Dict[ResolvedDependency, Any]
20
30
  unresolved: List[str]
@@ -23,20 +33,23 @@ class MethodDependency:
23
33
  """
24
34
  Validates types and values of attributes during initialization.
25
35
 
26
- Raises:
27
- TypeError: If types don't match the expected:
36
+ Raises
37
+ ------
38
+ ReflectionTypeError
39
+ If types don't match the expected:
28
40
  - resolved: Dict[ResolvedDependency, Any]
29
41
  - unresolved: List[str]
30
- ValueError: If resolved contains None keys or unresolved contains empty strings
42
+ ValueError
43
+ If resolved contains None keys or unresolved contains empty strings
31
44
  """
32
45
  # Validate 'resolved' is a dict with proper key types
33
46
  if not isinstance(self.resolved, dict):
34
- raise TypeError(
47
+ raise ReflectionTypeError(
35
48
  f"'resolved' must be a dict, got {type(self.resolved).__name__}"
36
49
  )
37
50
 
38
51
  # Validate 'unresolved' is a list of valid parameter names
39
52
  if not isinstance(self.unresolved, list):
40
- raise TypeError(
53
+ raise ReflectionTypeError(
41
54
  f"'unresolved' must be a list, got {type(self.unresolved).__name__}"
42
55
  )
@@ -1,23 +1,33 @@
1
1
  from dataclasses import dataclass
2
2
  from typing import Type, Any
3
3
 
4
+ from orionis.services.introspection.exceptions.reflection_type_error import ReflectionTypeError
5
+
4
6
  @dataclass(frozen=True, kw_only=True)
5
7
  class ResolvedDependency:
6
8
  """
7
9
  Represents a fully resolved dependency with complete type information.
8
10
 
9
- Attributes:
10
- module_name (str):
11
- The name of the module where the dependency is defined.
12
- Must be a non-empty string without spaces.
13
- class_name (str):
14
- The name of the class/type being resolved.
15
- Must be a valid Python identifier.
16
- type (Type):
17
- The actual Python type object of the resolved dependency.
18
- full_class_path (str):
19
- The full import path to the class (e.g., 'package.module.ClassName').
20
- Must match 'module_name.class_name' pattern.
11
+ Parameters
12
+ ----------
13
+ module_name : str
14
+ The name of the module where the dependency is defined.
15
+ Must be a non-empty string without spaces.
16
+ class_name : str
17
+ The name of the class/type being resolved.
18
+ Must be a valid Python identifier.
19
+ type : Type
20
+ The actual Python type object of the resolved dependency.
21
+ full_class_path : str
22
+ The full import path to the class (e.g., 'package.module.ClassName').
23
+ Must match 'module_name.class_name' pattern.
24
+
25
+ Raises
26
+ ------
27
+ ReflectionTypeError
28
+ If any field has incorrect type.
29
+ ValueError
30
+ If string fields are empty or don't meet format requirements.
21
31
  """
22
32
  module_name: str
23
33
  class_name: str
@@ -28,17 +38,20 @@ class ResolvedDependency:
28
38
  """
29
39
  Validates all fields during initialization.
30
40
 
31
- Raises:
32
- TypeError: If any field has incorrect type.
33
- ValueError: If string fields are empty or don't meet format requirements.
41
+ Raises
42
+ ------
43
+ ReflectionTypeError
44
+ If any field has incorrect type.
45
+ ValueError
46
+ If string fields are empty or don't meet format requirements.
34
47
  """
35
48
  # Validate module_name
36
49
  if not isinstance(self.module_name, str):
37
- raise TypeError(f"module_name must be str, got {type(self.module_name).__name__}")
50
+ raise ReflectionTypeError(f"module_name must be str, got {type(self.module_name).__name__}")
38
51
 
39
52
  # Validate class_name
40
53
  if not isinstance(self.class_name, str):
41
- raise TypeError(f"class_name must be str, got {type(self.class_name).__name__}")
54
+ raise ReflectionTypeError(f"class_name must be str, got {type(self.class_name).__name__}")
42
55
 
43
56
  # Validate type
44
57
  if self.type is None:
@@ -46,4 +59,4 @@ class ResolvedDependency:
46
59
 
47
60
  # Validate full_class_path
48
61
  if not isinstance(self.full_class_path, str):
49
- raise TypeError(f"full_class_path must be str, got {type(self.full_class_path).__name__}")
62
+ raise ReflectionTypeError(f"full_class_path must be str, got {type(self.full_class_path).__name__}")
@@ -4,6 +4,7 @@ from orionis.services.introspection.dependencies.contracts.reflect_dependencies
4
4
  from orionis.services.introspection.dependencies.entities.class_dependencies import ClassDependency
5
5
  from orionis.services.introspection.dependencies.entities.method_dependencies import MethodDependency
6
6
  from orionis.services.introspection.dependencies.entities.resolved_dependencies import ResolvedDependency
7
+ from orionis.services.introspection.exceptions.reflection_value_error import ReflectionValueError
7
8
 
8
9
  class ReflectDependencies(IReflectDependencies):
9
10
  """
@@ -67,16 +68,16 @@ class ReflectDependencies(IReflectDependencies):
67
68
 
68
69
  Raises
69
70
  ------
70
- ValueError
71
+ ReflectionValueError
71
72
  If the signature cannot be inspected.
72
73
  """
73
74
  if not callable(target):
74
- raise ValueError(f"Target {target} is not callable and cannot have a signature.")
75
+ raise ReflectionValueError(f"Target {target} is not callable and cannot have a signature.")
75
76
 
76
77
  try:
77
78
  return inspect.signature(target)
78
- except (ValueError, TypeError) as e:
79
- raise ValueError(f"Unable to inspect signature of {target}: {str(e)}")
79
+ except (ReflectionValueError, TypeError, Exception) as e:
80
+ raise ReflectionValueError(f"Unable to inspect signature of {target}: {str(e)}")
80
81
 
81
82
  def getConstructorDependencies(self) -> ClassDependency:
82
83
  """
@@ -0,0 +1,26 @@
1
+ class ReflectionAttributeError(Exception):
2
+ """
3
+ Base class for all reflection-related exceptions.
4
+ """
5
+
6
+ def __init__(self, msg: str):
7
+ """
8
+ Initialize the exception with a custom error message.
9
+
10
+ Parameters
11
+ ----------
12
+ msg : str
13
+ The error message describing the exception.
14
+ """
15
+ super().__init__(msg)
16
+
17
+ def __str__(self) -> str:
18
+ """
19
+ Return a string representation of the exception, including the class name and the first argument.
20
+
21
+ Returns
22
+ -------
23
+ str
24
+ A formatted string with the exception class name and the first argument.
25
+ """
26
+ return f"{self.__class__.__name__}: {self.args[0]}"
@@ -0,0 +1,26 @@
1
+ class ReflectionTypeError(Exception):
2
+ """
3
+ Base class for all reflection-related exceptions.
4
+ """
5
+
6
+ def __init__(self, msg: str):
7
+ """
8
+ Initialize the exception with a custom error message.
9
+
10
+ Parameters
11
+ ----------
12
+ msg : str
13
+ The error message describing the exception.
14
+ """
15
+ super().__init__(msg)
16
+
17
+ def __str__(self) -> str:
18
+ """
19
+ Return a string representation of the exception, including the class name and the first argument.
20
+
21
+ Returns
22
+ -------
23
+ str
24
+ A formatted string with the exception class name and the first argument.
25
+ """
26
+ return f"{self.__class__.__name__}: {self.args[0]}"
@@ -0,0 +1,26 @@
1
+ class ReflectionValueError(Exception):
2
+ """
3
+ Base class for all reflection-related exceptions.
4
+ """
5
+
6
+ def __init__(self, msg: str):
7
+ """
8
+ Initialize the exception with a custom error message.
9
+
10
+ Parameters
11
+ ----------
12
+ msg : str
13
+ The error message describing the exception.
14
+ """
15
+ super().__init__(msg)
16
+
17
+ def __str__(self) -> str:
18
+ """
19
+ Return a string representation of the exception, including the class name and the first argument.
20
+
21
+ Returns
22
+ -------
23
+ str
24
+ A formatted string with the exception class name and the first argument.
25
+ """
26
+ return f"{self.__class__.__name__}: {self.args[0]}"
@@ -0,0 +1,20 @@
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]
@@ -0,0 +1,41 @@
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]
@@ -0,0 +1,24 @@
1
+ from dataclasses import dataclass
2
+ import inspect
3
+ from typing import Any
4
+
5
+ @dataclass(frozen=True, kw_only=True)
6
+ class ClassProperty:
7
+ """
8
+ Represents a property of a class with its metadata.
9
+
10
+ Parameters
11
+ ----------
12
+ name : str
13
+ The name of the property.
14
+ value : Any
15
+ The value assigned to the property.
16
+ signature : inspect.Signature
17
+ The signature of the property, typically used for callable properties.
18
+ doc : str
19
+ The documentation string associated with the property.
20
+ """
21
+ name: str
22
+ value: Any
23
+ signature: inspect.Signature
24
+ doc: str