orionis 0.450.0__py3-none-any.whl → 0.451.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 (42) hide show
  1. orionis/console/base/contracts/command.py +0 -2
  2. orionis/console/core/__init__.py +0 -0
  3. orionis/container/container.py +1577 -69
  4. orionis/container/contracts/container.py +184 -33
  5. orionis/foundation/config/database/entities/mysql.py +0 -1
  6. orionis/metadata/framework.py +1 -1
  7. orionis/services/inspirational/contracts/__init__.py +0 -0
  8. orionis/services/introspection/abstract/contracts/reflection.py +5 -6
  9. orionis/services/introspection/abstract/reflection.py +5 -6
  10. orionis/services/introspection/callables/contracts/reflection.py +3 -2
  11. orionis/services/introspection/callables/reflection.py +4 -4
  12. orionis/services/introspection/concretes/contracts/reflection.py +5 -6
  13. orionis/services/introspection/concretes/reflection.py +5 -6
  14. orionis/services/introspection/dependencies/contracts/reflection.py +87 -23
  15. orionis/services/introspection/dependencies/entities/argument.py +95 -0
  16. orionis/services/introspection/dependencies/entities/resolve_argument.py +82 -0
  17. orionis/services/introspection/dependencies/reflection.py +176 -106
  18. orionis/services/introspection/instances/contracts/reflection.py +5 -6
  19. orionis/services/introspection/instances/reflection.py +5 -6
  20. orionis/test/core/unit_test.py +150 -48
  21. {orionis-0.450.0.dist-info → orionis-0.451.0.dist-info}/METADATA +1 -1
  22. {orionis-0.450.0.dist-info → orionis-0.451.0.dist-info}/RECORD +34 -37
  23. tests/container/mocks/mock_auto_resolution.py +192 -0
  24. tests/services/introspection/dependencies/test_reflect_dependencies.py +135 -58
  25. tests/services/introspection/reflection/test_reflection_abstract.py +5 -4
  26. tests/services/introspection/reflection/test_reflection_callable.py +3 -3
  27. tests/services/introspection/reflection/test_reflection_concrete.py +4 -4
  28. tests/services/introspection/reflection/test_reflection_instance.py +5 -5
  29. orionis/console/args/parser.py +0 -40
  30. orionis/container/contracts/resolver.py +0 -115
  31. orionis/container/resolver/resolver.py +0 -602
  32. orionis/services/introspection/dependencies/entities/callable_dependencies.py +0 -54
  33. orionis/services/introspection/dependencies/entities/class_dependencies.py +0 -61
  34. orionis/services/introspection/dependencies/entities/known_dependencies.py +0 -67
  35. orionis/services/introspection/dependencies/entities/method_dependencies.py +0 -61
  36. tests/container/resolver/test_resolver.py +0 -62
  37. /orionis/{container/resolver → console/commands}/__init__.py +0 -0
  38. {tests/container/resolver → orionis/console/contracts}/__init__.py +0 -0
  39. {orionis-0.450.0.dist-info → orionis-0.451.0.dist-info}/WHEEL +0 -0
  40. {orionis-0.450.0.dist-info → orionis-0.451.0.dist-info}/licenses/LICENCE +0 -0
  41. {orionis-0.450.0.dist-info → orionis-0.451.0.dist-info}/top_level.txt +0 -0
  42. {orionis-0.450.0.dist-info → orionis-0.451.0.dist-info}/zip-safe +0 -0
@@ -1,11 +1,7 @@
1
1
  import asyncio
2
- from orionis.services.introspection.dependencies.entities.callable_dependencies import CallableDependency
3
- from orionis.services.introspection.dependencies.reflection import (
4
- ReflectDependencies,
5
- ClassDependency,
6
- MethodDependency,
7
- KnownDependency
8
- )
2
+ from orionis.services.introspection.dependencies.entities.argument import Argument
3
+ from orionis.services.introspection.dependencies.entities.resolve_argument import ResolveArguments
4
+ from orionis.services.introspection.dependencies.reflection import ReflectDependencies
9
5
  from orionis.test.cases.asynchronous import AsyncTestCase
10
6
  from tests.services.introspection.dependencies.mocks.mock_user import FakeUser
11
7
  from tests.services.introspection.dependencies.mocks.mock_user_controller import UserController
@@ -47,134 +43,215 @@ class TestReflectDependencies(AsyncTestCase):
47
43
  """
48
44
  Retrieves and validates the constructor dependencies for the UserController class using the ReflectDependencies utility.
49
45
 
46
+ This test method verifies the correct functioning of dependency introspection for class constructors.
47
+ It ensures that the ReflectDependencies class can properly analyze and resolve constructor parameters,
48
+ returning them in the expected format with correct type information and metadata.
49
+
50
50
  Parameters
51
51
  ----------
52
52
  self : TestReflectDependencies
53
- The test case instance.
53
+ The test case instance containing the test context and assertion methods.
54
54
 
55
55
  Returns
56
56
  -------
57
57
  None
58
+ This test method does not return any value. It performs assertions to validate the dependency
59
+ resolution functionality and will raise AssertionError if any validation fails.
58
60
 
59
61
  Notes
60
62
  -----
61
- This test ensures that:
62
- - The returned constructor dependencies are an instance of ClassDependency.
63
- - The list of unresolved dependencies is empty.
64
- - The 'user_repository' dependency is resolved as an instance of KnownDependency.
65
- - The resolved dependency for 'user_repository' has the expected module name, class name, full class path, and type (FakeUser).
63
+ This test validates the following aspects of constructor dependency resolution:
64
+ - The returned constructor dependencies are an instance of ResolveArguments.
65
+ - The unresolved dependencies dictionary is properly structured.
66
+ - The 'user_repository' dependency is resolved as an instance of Argument.
67
+ - The resolved dependency for 'user_repository' contains accurate metadata including
68
+ module name, class name, full class path, and type reference (FakeUser).
66
69
  """
67
70
 
71
+ # Initialize the ReflectDependencies utility with the UserController class
68
72
  depend = ReflectDependencies(UserController)
73
+
74
+ # Retrieve constructor dependencies for analysis
69
75
  constructor_dependencies = depend.getConstructorDependencies()
70
76
 
71
- # Check Instance of ClassDependency
72
- self.assertIsInstance(constructor_dependencies, ClassDependency)
77
+ # Validate that the result is an instance of ResolveArguments
78
+ self.assertIsInstance(constructor_dependencies, ResolveArguments)
73
79
 
74
- self.assertEqual(constructor_dependencies.unresolved, [])
80
+ # Verify that unresolved dependencies are returned as a dictionary structure
81
+ self.assertIsInstance(constructor_dependencies.unresolved, dict)
75
82
 
76
- # Check Instance of KnownDependency
83
+ # Extract the 'user_repository' dependency from resolved dependencies
77
84
  dep_user_repository = constructor_dependencies.resolved.get('user_repository')
78
- self.assertIsInstance(dep_user_repository, KnownDependency)
79
85
 
80
- # Check resolved dependencies for 'user_repository'
81
- dependencies:KnownDependency = dep_user_repository
86
+ # Validate that the dependency is properly resolved as an Argument instance
87
+ self.assertIsInstance(dep_user_repository, Argument)
88
+
89
+ # Perform detailed validation of the resolved dependency metadata
90
+ dependencies: Argument = dep_user_repository
91
+
92
+ # Verify the module name matches the expected mock module
82
93
  self.assertEqual(dependencies.module_name, 'tests.services.introspection.dependencies.mocks.mock_user')
94
+
95
+ # Verify the class name matches the expected FakeUser class
83
96
  self.assertEqual(dependencies.class_name, 'FakeUser')
97
+
98
+ # Verify the full class path is correctly constructed
84
99
  self.assertEqual(dependencies.full_class_path, 'tests.services.introspection.dependencies.mocks.mock_user.FakeUser')
100
+
101
+ # Verify the type reference points to the actual FakeUser class
85
102
  self.assertEqual(dependencies.type, FakeUser)
86
103
 
87
104
  async def testReflectionDependenciesGetMethodDependencies(self):
88
105
  """
89
- Retrieves and validates the dependencies for the 'createUserWithPermissions' method of the UserController class
90
- using the ReflectDependencies utility.
106
+ Test the retrieval and validation of method dependencies for the UserController class.
91
107
 
92
- This test ensures that:
93
- - The returned object is an instance of MethodDependency.
94
- - The unresolved dependencies list is empty.
95
- - The 'user_permissions' dependency is resolved as a KnownDependency with the expected module name,
96
- class name, full class path, and type (FakeUserWithPermissions).
97
- - The 'permissions' dependency is resolved as a KnownDependency with the expected module name,
98
- class name, full class path, and type (list[str]).
108
+ This test method validates the ReflectDependencies utility's ability to introspect and resolve
109
+ dependencies for a specific method ('createUserWithPermissions') within a target class.
110
+ It ensures that all method parameters are correctly identified, resolved, and contain
111
+ accurate metadata including module information, class names, and type references.
112
+
113
+ The test performs comprehensive validation of:
114
+ - The returned dependency resolution object structure and type
115
+ - The absence of unresolved dependencies when all parameters can be resolved
116
+ - The correct resolution of complex type dependencies (custom classes)
117
+ - The accurate resolution of built-in type dependencies (generic types with parameters)
118
+ - The proper extraction of module paths, class names, and full qualified paths
119
+ - The correct type reference mapping for both custom and built-in types
99
120
 
100
121
  Parameters
101
122
  ----------
102
123
  self : TestReflectDependencies
103
- The test case instance.
124
+ The test case instance containing assertion methods and test context.
104
125
 
105
126
  Returns
106
127
  -------
107
128
  None
129
+ This method performs assertions and does not return any value. Test failure
130
+ will raise AssertionError if any validation fails.
131
+
132
+ Notes
133
+ -----
134
+ This test specifically validates two types of dependencies:
135
+ - Custom class dependencies (FakeUserWithPermissions) with full module path resolution
136
+ - Built-in generic type dependencies (list[str]) with proper type parameter handling
137
+
138
+ The test ensures that the ReflectDependencies utility correctly handles both
139
+ user-defined classes and Python built-in generic types when analyzing method signatures.
108
140
  """
109
141
 
142
+ # Initialize the ReflectDependencies utility with UserController as the target class
110
143
  depend = ReflectDependencies(UserController)
144
+
145
+ # Retrieve method dependencies for the 'createUserWithPermissions' method
111
146
  method_dependencies = depend.getMethodDependencies('createUserWithPermissions')
112
147
 
113
- # Check Instance of MethodDependency
114
- self.assertIsInstance(method_dependencies, MethodDependency)
148
+ # Validate that the result is an instance of ResolveArguments (dependency resolution container)
149
+ self.assertIsInstance(method_dependencies, ResolveArguments)
115
150
 
116
- # Check unresolved dependencies
117
- self.assertEqual(method_dependencies.unresolved, [])
151
+ # Verify that unresolved dependencies are returned as a dictionary structure
152
+ self.assertIsInstance(method_dependencies.unresolved, dict)
118
153
 
119
- # Check Instance of KnownDependency for 'user_permissions'
120
- dep_user_permissions:KnownDependency = method_dependencies.resolved.get('user_permissions')
121
- self.assertIsInstance(dep_user_permissions, KnownDependency)
154
+ # Extract and validate the 'user_permissions' dependency from resolved dependencies
155
+ dep_user_permissions: Argument = method_dependencies.resolved.get('user_permissions')
122
156
 
123
- # Check resolved dependencies for 'user_permissions'
157
+ # Ensure the dependency is properly resolved as an Argument instance
158
+ self.assertIsInstance(dep_user_permissions, Argument)
159
+
160
+ # Validate the module name for the custom FakeUserWithPermissions class
124
161
  self.assertEqual(dep_user_permissions.module_name, 'tests.services.introspection.dependencies.mocks.mock_users_permissions')
162
+
163
+ # Validate the class name extraction for the custom class
125
164
  self.assertEqual(dep_user_permissions.class_name, 'FakeUserWithPermissions')
165
+
166
+ # Validate the full qualified class path construction
126
167
  self.assertEqual(dep_user_permissions.full_class_path, 'tests.services.introspection.dependencies.mocks.mock_users_permissions.FakeUserWithPermissions')
168
+
169
+ # Validate the type reference points to the actual FakeUserWithPermissions class
127
170
  self.assertEqual(dep_user_permissions.type, FakeUserWithPermissions)
128
171
 
129
- # Check Instance of KnownDependency for 'permissions'
130
- dep_permissions:KnownDependency = method_dependencies.resolved.get('permissions')
131
- self.assertIsInstance(dep_permissions, KnownDependency)
172
+ # Extract and validate the 'permissions' dependency (built-in generic type)
173
+ dep_permissions: Argument = method_dependencies.resolved.get('permissions')
132
174
 
133
- # Check resolved dependencies for 'permissions'
175
+ # Ensure the built-in type dependency is properly resolved as an Argument instance
176
+ self.assertIsInstance(dep_permissions, Argument)
177
+
178
+ # Validate the module name for built-in types (should be 'builtins')
134
179
  self.assertEqual(dep_permissions.module_name, 'builtins')
180
+
181
+ # Validate the base class name for the generic list type
135
182
  self.assertEqual(dep_permissions.class_name, 'list')
183
+
184
+ # Validate the full qualified path for built-in types
136
185
  self.assertEqual(dep_permissions.full_class_path, 'builtins.list')
186
+
187
+ # Validate the type reference includes generic type parameters (list[str])
137
188
  self.assertEqual(dep_permissions.type, list[str])
138
189
 
139
190
  async def testReflectionDependenciesGetCallableDependencies(self):
140
191
  """
141
- Tests the `getCallableDependencies` method of the `ReflectDependencies` class for a given asynchronous function.
192
+ Test the retrieval and validation of callable dependencies for a standalone asynchronous function.
193
+
194
+ This test method validates the ReflectDependencies utility's ability to introspect and resolve
195
+ dependencies for a standalone callable function (not bound to a class). It ensures that function
196
+ parameters with default values are correctly identified and resolved, and that the dependency
197
+ resolution process handles callable introspection appropriately.
198
+
199
+ The test performs comprehensive validation of:
200
+ - The returned dependency resolution object structure and type
201
+ - The absence of unresolved dependencies when all parameters have default values
202
+ - The correct resolution of parameters with default values to their actual default values
203
+ - The proper handling of built-in type annotations (int) for function parameters
204
+ - The validation that resolved dependencies contain the expected default values
142
205
 
143
206
  Parameters
144
207
  ----------
145
208
  self : TestReflectDependencies
146
- The test case instance.
209
+ The test case instance containing assertion methods and test context.
147
210
 
148
211
  Returns
149
212
  -------
150
213
  None
214
+ This method performs assertions and does not return any value. Test failure
215
+ will raise AssertionError if any validation fails.
151
216
 
152
217
  Notes
153
218
  -----
154
- This test checks that:
155
- - The returned dependencies are an instance of `CallableDependency`.
156
- - There are no unresolved dependencies.
157
- - The 'x' and 'y' parameters are resolved to their default integer values (3 and 4, respectively).
219
+ This test specifically validates callable dependency resolution for:
220
+ - Asynchronous functions with type-annotated parameters
221
+ - Parameters with default values (integers in this case)
222
+ - The correct mapping of parameter names to their default values
223
+
224
+ The test ensures that the ReflectDependencies utility correctly handles standalone
225
+ callable functions and resolves their parameters to appropriate default values
226
+ when those defaults are provided in the function signature.
158
227
  """
159
228
 
229
+ # Define a sample asynchronous function with default parameter values for testing
160
230
  async def fake_function(x: int = 3, y: int = 4) -> int:
161
231
  """Asynchronously adds two integers with a short delay."""
162
232
  await asyncio.sleep(0.1)
163
233
  return x + y
164
234
 
165
- depend = ReflectDependencies()
166
- callable_dependencies = depend.getCallableDependencies(fake_function)
235
+ # Initialize the ReflectDependencies utility with the callable function as target
236
+ depend = ReflectDependencies(fake_function)
167
237
 
168
- # Check Instance of MethodDependency
169
- self.assertIsInstance(callable_dependencies, CallableDependency)
238
+ # Retrieve callable dependencies for analysis
239
+ callable_dependencies = depend.getCallableDependencies()
170
240
 
171
- # Check unresolved dependencies
172
- self.assertEqual(callable_dependencies.unresolved, [])
241
+ # Validate that the result is an instance of ResolveArguments (dependency resolution container)
242
+ self.assertIsInstance(callable_dependencies, ResolveArguments)
173
243
 
174
- # Check Instance of KnownDependency for 'x'
175
- dep_x:KnownDependency = callable_dependencies.resolved.get('x')
244
+ # Verify that unresolved dependencies are returned as a dictionary structure
245
+ self.assertIsInstance(callable_dependencies.unresolved, dict)
246
+
247
+ # Extract and validate the 'x' parameter dependency from resolved dependencies
248
+ dep_x: Argument = callable_dependencies.resolved.get('x')
249
+
250
+ # Verify that the 'x' parameter resolves to its default value of 3
176
251
  self.assertEqual(dep_x, 3)
177
252
 
178
- # Check Instance of KnownDependency for 'y'
179
- dep_y:KnownDependency = callable_dependencies.resolved.get('y')
253
+ # Extract and validate the 'y' parameter dependency from resolved dependencies
254
+ dep_y: Argument = callable_dependencies.resolved.get('y')
255
+
256
+ # Verify that the 'y' parameter resolves to its default value of 4
180
257
  self.assertEqual(dep_y, 4)
@@ -1,5 +1,6 @@
1
1
  from orionis.services.introspection.abstract.reflection import ReflectionAbstract
2
- from orionis.services.introspection.dependencies.entities.class_dependencies import ClassDependency
2
+ from orionis.services.introspection.dependencies.entities.argument import Argument
3
+ from orionis.services.introspection.dependencies.entities.resolve_argument import ResolveArguments
3
4
  from tests.services.introspection.reflection.mock.fake_reflect_instance import AbstractFakeClass
4
5
  from orionis.test.cases.asynchronous import AsyncTestCase
5
6
 
@@ -987,11 +988,11 @@ class TestServiceReflectionAbstract(AsyncTestCase):
987
988
 
988
989
  Assertions
989
990
  ----------
990
- Should return a ClassDependency instance with constructor dependencies.
991
+ Should return a ResolveArguments instance with constructor dependencies.
991
992
  """
992
993
  reflect = ReflectionAbstract(AbstractFakeClass)
993
994
  dependencies = reflect.getConstructorDependencies()
994
- self.assertIsInstance(dependencies, ClassDependency)
995
+ self.assertIsInstance(dependencies, ResolveArguments)
995
996
 
996
997
  async def testGetMethodDependencies(self):
997
998
  """
@@ -1005,7 +1006,7 @@ class TestServiceReflectionAbstract(AsyncTestCase):
1005
1006
  Should return method dependencies with correct parameter types and metadata.
1006
1007
  """
1007
1008
  reflect = ReflectionAbstract(AbstractFakeClass)
1008
- method_deps = reflect.getMethodDependencies('instanceSyncMethod')
1009
+ method_deps: ResolveArguments = reflect.getMethodDependencies('instanceSyncMethod')
1009
1010
  self.assertIn('x', method_deps.resolved)
1010
1011
  self.assertIn('y', method_deps.resolved)
1011
1012
  self.assertEqual(method_deps.resolved['x'].class_name, 'int')
@@ -1,5 +1,5 @@
1
1
  from orionis.services.introspection.callables.reflection import ReflectionCallable
2
- from orionis.services.introspection.dependencies.entities.callable_dependencies import CallableDependency
2
+ from orionis.services.introspection.dependencies.entities.resolve_argument import ResolveArguments
3
3
  from orionis.test.cases.asynchronous import AsyncTestCase
4
4
  from orionis.services.introspection.exceptions import ReflectionTypeError
5
5
 
@@ -189,7 +189,7 @@ class TestReflectionCallable(AsyncTestCase):
189
189
  """
190
190
  Test retrieval of callable dependencies from ReflectionCallable.
191
191
 
192
- Checks that getDependencies() returns a CallableDependency object with
192
+ Checks that getDependencies() returns a ResolveArguments object with
193
193
  'resolved' and 'unresolved' attributes for the wrapped function.
194
194
 
195
195
  Returns
@@ -201,6 +201,6 @@ class TestReflectionCallable(AsyncTestCase):
201
201
  return a + b
202
202
  rc = ReflectionCallable(sample_function)
203
203
  deps = rc.getDependencies()
204
- self.assertIsInstance(deps, CallableDependency)
204
+ self.assertIsInstance(deps, ResolveArguments)
205
205
  self.assertTrue(hasattr(deps, "resolved"))
206
206
  self.assertTrue(hasattr(deps, "unresolved"))
@@ -1,5 +1,5 @@
1
1
  from orionis.services.introspection.concretes.reflection import ReflectionConcrete
2
- from orionis.services.introspection.dependencies.entities.class_dependencies import ClassDependency
2
+ from orionis.services.introspection.dependencies.entities.resolve_argument import ResolveArguments
3
3
  from tests.services.introspection.reflection.mock.fake_reflect_instance import FakeClass
4
4
  from orionis.test.cases.asynchronous import AsyncTestCase
5
5
 
@@ -931,11 +931,11 @@ class TestServiceReflectionConcrete(AsyncTestCase):
931
931
  Returns
932
932
  -------
933
933
  None
934
- Asserts that the returned dependencies are a ClassDependency object.
934
+ Asserts that the returned dependencies are a ResolveArguments object.
935
935
  """
936
936
  reflect = ReflectionConcrete(FakeClass)
937
937
  dependencies = reflect.getConstructorDependencies()
938
- self.assertIsInstance(dependencies, ClassDependency)
938
+ self.assertIsInstance(dependencies, ResolveArguments)
939
939
 
940
940
  async def testGetMethodDependencies(self):
941
941
  """
@@ -947,7 +947,7 @@ class TestServiceReflectionConcrete(AsyncTestCase):
947
947
  Asserts that the returned dependencies for 'instanceSyncMethod' are as expected.
948
948
  """
949
949
  reflect = ReflectionConcrete(FakeClass)
950
- method_deps = reflect.getMethodDependencies('instanceSyncMethod')
950
+ method_deps: ResolveArguments = reflect.getMethodDependencies('instanceSyncMethod')
951
951
  self.assertIn('x', method_deps.resolved)
952
952
  self.assertIn('y', method_deps.resolved)
953
953
  self.assertEqual(method_deps.resolved['x'].class_name, 'int')
@@ -1,4 +1,4 @@
1
- from orionis.services.introspection.dependencies.entities.class_dependencies import ClassDependency
1
+ from orionis.services.introspection.dependencies.entities.resolve_argument import ResolveArguments
2
2
  from tests.services.introspection.reflection.mock.fake_reflect_instance import FakeClass
3
3
  from orionis.services.introspection.instances.reflection import ReflectionInstance
4
4
  from orionis.test.cases.asynchronous import AsyncTestCase
@@ -1201,16 +1201,16 @@ class TestServiceReflectionInstance(AsyncTestCase):
1201
1201
  Test ReflectionInstance.getConstructorDependencies() method functionality.
1202
1202
 
1203
1203
  Verifies that the getConstructorDependencies method returns an instance
1204
- of ClassDependency containing the constructor dependencies of the wrapped
1204
+ of ResolveArguments containing the constructor dependencies of the wrapped
1205
1205
  instance's class. Tests dependency analysis for class constructors.
1206
1206
 
1207
1207
  Assertions
1208
1208
  ----------
1209
- - Returned value is an instance of ClassDependency
1209
+ - Returned value is an instance of ResolveArguments
1210
1210
  """
1211
1211
  reflect = ReflectionInstance(FakeClass())
1212
1212
  dependencies = reflect.getConstructorDependencies()
1213
- self.assertIsInstance(dependencies, ClassDependency)
1213
+ self.assertIsInstance(dependencies, ResolveArguments)
1214
1214
 
1215
1215
  async def testGetMethodDependencies(self):
1216
1216
  """
@@ -1228,7 +1228,7 @@ class TestServiceReflectionInstance(AsyncTestCase):
1228
1228
  - No unresolved dependencies exist
1229
1229
  """
1230
1230
  reflect = ReflectionInstance(FakeClass())
1231
- method_deps = reflect.getMethodDependencies('instanceSyncMethod')
1231
+ method_deps: ResolveArguments = reflect.getMethodDependencies('instanceSyncMethod')
1232
1232
  self.assertIn('x', method_deps.resolved)
1233
1233
  self.assertIn('y', method_deps.resolved)
1234
1234
  self.assertEqual(method_deps.resolved['x'].class_name, 'int')
@@ -1,40 +0,0 @@
1
- import argparse
2
-
3
- class ArgumentPaser():
4
-
5
- def __init__(self):
6
- self.__parser = argparse.ArgumentParser()
7
-
8
- def addArgument(self, name: str, **kwargs):
9
- """
10
- Add an argument to the parser.
11
-
12
- Parameters
13
- ----------
14
- name : str
15
- The name of the argument to add.
16
- kwargs : dict
17
- Additional keyword arguments for the argument configuration.
18
-
19
- Returns
20
- -------
21
- None
22
- This method does not return any value.
23
- """
24
- self.__parser.add_argument(name, **kwargs)
25
-
26
- def parse(self, args=None):
27
- """
28
- Parse the command-line arguments.
29
-
30
- Parameters
31
- ----------
32
- args : list, optional
33
- A list of arguments to parse. If None, uses sys.argv by default.
34
-
35
- Returns
36
- -------
37
- Namespace
38
- An object containing the parsed arguments as attributes.
39
- """
40
- return self.__parser.parse_args(args)
@@ -1,115 +0,0 @@
1
- from abc import ABC, abstractmethod
2
- from typing import Any, Callable
3
- from orionis.container.contracts.container import IContainer
4
- from orionis.container.entities.binding import Binding
5
- from orionis.services.introspection.dependencies.entities.method_dependencies import MethodDependency
6
-
7
- class IResolver(ABC):
8
- """
9
- Interface for dependency resolution in the container system.
10
-
11
- This interface defines the contract for resolvers that handle
12
- dependency injection and instance creation based on bindings.
13
- """
14
-
15
- @abstractmethod
16
- def __init__(self, container: IContainer) -> None:
17
- """
18
- Initialize the resolver with a container reference.
19
-
20
- Parameters
21
- ----------
22
- container : IContainer
23
- The container instance that this resolver will use to resolve dependencies.
24
- """
25
- pass
26
-
27
- @abstractmethod
28
- def resolve(
29
- self,
30
- binding: Binding,
31
- *args,
32
- **kwargs
33
- ) -> Any:
34
- """
35
- Resolves an instance from a binding.
36
-
37
- This method resolves an instance based on the binding's lifetime and type.
38
- It delegates to specific resolution methods based on the lifetime (transient, singleton, or scoped).
39
-
40
- Parameters
41
- ----------
42
- binding : Binding
43
- The binding to resolve.
44
- *args : tuple
45
- Additional positional arguments to pass to the constructor.
46
- **kwargs : dict
47
- Additional keyword arguments to pass to the constructor.
48
-
49
- Returns
50
- -------
51
- Any
52
- The resolved instance.
53
-
54
- Raises
55
- ------
56
- OrionisContainerException
57
- If the binding is not an instance of Binding or if resolution fails.
58
- """
59
- pass
60
-
61
- @abstractmethod
62
- def resolveType(
63
- self,
64
- type_: Callable[..., Any],
65
- *args,
66
- **kwargs
67
- ) -> Any:
68
- """
69
- Forces resolution of a type whether it's registered in the container or not.
70
-
71
- Parameters
72
- ----------
73
- type_ : Callable[..., Any]
74
- The type or callable to resolve.
75
- *args : tuple
76
- Positional arguments to pass to the constructor/callable.
77
- **kwargs : dict
78
- Keyword arguments to pass to the constructor/callable.
79
-
80
- Returns
81
- -------
82
- Any
83
- The resolved instance.
84
-
85
- Raises
86
- ------
87
- OrionisContainerException
88
- If the type cannot be resolved.
89
- """
90
- pass
91
-
92
- @abstractmethod
93
- def resolveSignature(
94
- self,
95
- signature: MethodDependency
96
- ) -> dict:
97
- """
98
- Resolves dependencies defined in a method signature.
99
-
100
- Parameters
101
- ----------
102
- signature : MethodDependency
103
- The method dependency information to resolve.
104
-
105
- Returns
106
- -------
107
- dict
108
- A dictionary of resolved parameter values.
109
-
110
- Raises
111
- ------
112
- OrionisContainerException
113
- If any dependencies cannot be resolved.
114
- """
115
- pass