Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def register(
self, service, factory=empty, instance=empty, scope=Scope.transient, **kwargs
):
resolve_args = kwargs or {}
if instance is not empty:
self.register_service_and_instance(service, instance)
elif factory is empty:
self.register_concrete_service(service, scope)
elif callable(factory):
self.register_service_and_impl(service, scope, factory, resolve_args)
else:
raise InvalidRegistrationException(
f"Expected a callable factory for the service {service} but received {factory}"
)
self._update_localns(service)
ensure_forward_ref(self, service, factory, instance, **kwargs)