diff --git a/docs/main/changelog.rst b/docs/main/changelog.rst index 45021391..672b14dc 100644 --- a/docs/main/changelog.rst +++ b/docs/main/changelog.rst @@ -12,6 +12,7 @@ Dev version - Fix ``@containers.copy()`` decorator to respect dependencies on parent providers. See issue `#477 `_. Thanks to `Andrey Torsunov @gtors `_ for reporting the issue. +- Fix typing stub for ``container.override_providers()`` to accept other types besides ``Provider``. 4.35.2 ------ diff --git a/src/dependency_injector/containers.pyi b/src/dependency_injector/containers.pyi index af398e3b..1357f2f1 100644 --- a/src/dependency_injector/containers.pyi +++ b/src/dependency_injector/containers.pyi @@ -40,7 +40,7 @@ class Container: def set_providers(self, **providers: Provider): ... def set_provider(self, name: str, provider: Provider) -> None: ... def override(self, overriding: C_Base) -> None: ... - def override_providers(self, **overriding_providers: Provider) -> None: ... + def override_providers(self, **overriding_providers: Union[Provider, Any]) -> None: ... def reset_last_overriding(self) -> None: ... def reset_override(self) -> None: ... def wire(self, modules: Optional[Iterable[Any]] = None, packages: Optional[Iterable[Any]] = None) -> None: ... diff --git a/tests/typing/declarative_container.py b/tests/typing/declarative_container.py index b5922e77..51356514 100644 --- a/tests/typing/declarative_container.py +++ b/tests/typing/declarative_container.py @@ -56,3 +56,11 @@ class Container6(containers.DeclarativeContainer): container6: containers.Container = Container6() + + +# Test 7: to override() +class Container7(containers.DeclarativeContainer): + provider = providers.Factory(str) + +container7 = Container7() +container7.override_providers(provider='new_value')