docs: def register_factory(self, key, factory=_sentinel, scope=NoneScope, allow_overwrite=False):
          '''
          Creates and registers a provider using the given key, factory, and scope.
          Can also be used as a decorator.
  
          :param key: Provider key
          :type key:  object
          :param factory: Factory callable
          :type factory: callable
          :param scope: Scope key, factory, or instance
          :type scope: object or callable
          :return: Factory (or None if we're creating a provider without a factory)
          :rtype: callable or None
          '''
          if factory is _sentinel:
              return functools.partial(self.register_factory, key, scope=scope, allow_overwrite=allow_overwrite)
          if not allow_overwrite and key in self._providers:
              raise KeyError("Key %s already exists" % key)
          provider = self.provider(factory, scope)
          self._providers[key] = provider
          return factory