MCPcopy
hub / github.com/guardicore/monkey / _construct_new_instance

Method _construct_new_instance

monkey/common/di_container.py:186–192  ·  view source on GitHub ↗
(self, arg_type: Type[T])

Source from the content-addressed store, hash-verified

184 )
185
186 def _construct_new_instance(self, arg_type: Type[T]) -> T:
187 try:
188 return self._type_registry[arg_type]()
189 except TypeError:
190 # arg_type has dependencies that must be resolved. Recursively call resolve() to
191 # construct an instance of arg_type with all of the requesite dependencies injected.
192 return self.resolve(self._type_registry[arg_type])
193
194 def _retrieve_registered_instance(self, arg_type: Type[T]) -> T:
195 return self._instance_registry[arg_type]

Callers 1

_resolve_typeMethod · 0.95

Calls 1

resolveMethod · 0.95

Tested by

no test coverage detected