diff --git a/docs/pages/service_override.md b/docs/pages/service_override.md index d7b909e..cbc5e9a 100644 --- a/docs/pages/service_override.md +++ b/docs/pages/service_override.md @@ -11,11 +11,11 @@ which will help temporarily overriding dependencies !!! info "Good to know" - * Overriding only applies to subsequent autowire calls. - * If a singleton service has been initialized, it is not possible to override any - of its dependencies as the object is already in memory. You may need to override - the first service directly instead of any transient dependencies. - * When using interfaces override the interface rather than any impl. + * Overriding only applies to future autowire calls. + * If a singleton service A has been initialized, it is not possible to override any + of its dependencies as the object is already in memory. You may need to override + Service A directly instead of any transient dependencies. + * When using interfaces override the interface rather than any of its implementations. ## Example diff --git a/wireup/ioc/override_manager.py b/wireup/ioc/override_manager.py index cd50f10..fa9fa68 100644 --- a/wireup/ioc/override_manager.py +++ b/wireup/ioc/override_manager.py @@ -36,7 +36,7 @@ def clear(self) -> None: @contextmanager def service(self, target: type, new: Any, qualifier: ContainerProxyQualifierValue = None) -> Iterator[None]: - """Override the target service with new for the duration of the context manager. + """Override the `target` service with `new` for the duration of the context manager. Subsequent autowire calls to `target` will result in `new` being injected. @@ -53,10 +53,7 @@ def service(self, target: type, new: Any, qualifier: ContainerProxyQualifierValu @contextmanager def services(self, overrides: list[ServiceOverride]) -> Iterator[None]: - """Override the target service with new for the duration of the context manager. - - Behavior is identical to `override`, except this supports overriding multiple services at a time. - """ + """Override a number of services with new for the duration of the context manager.""" try: for override in overrides: self.set(override.target, override.new, override.qualifier)