From ce36033faa2298d17789817ad75b2c9bda6dedfe Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Sat, 6 Mar 2021 09:02:05 -0500 Subject: [PATCH] Add typing stubs for Callable, Factory, and Singleton .set_provides() attributes --- src/dependency_injector/providers.pyi | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/dependency_injector/providers.pyi b/src/dependency_injector/providers.pyi index 25865891..fca602da 100644 --- a/src/dependency_injector/providers.pyi +++ b/src/dependency_injector/providers.pyi @@ -131,9 +131,10 @@ class DependenciesContainer(Object): class Callable(Provider[T]): - def __init__(self, provides: _Callable[..., T], *args: Injection, **kwargs: Injection) -> None: ... + def __init__(self, provides: Optional[_Callable[..., T]] = None, *args: Injection, **kwargs: Injection) -> None: ... @property - def provides(self) -> T: ... + def provides(self) -> Optional[T]: ... + def set_provides(self, provides: Optional[_Callable[..., T]]) -> None: ... @property def args(self) -> Tuple[Injection]: ... def add_args(self, *args: Injection) -> Callable[T]: ... @@ -221,11 +222,12 @@ class Configuration(Object[Any]): class Factory(Provider[T]): provided_type: Optional[Type] - def __init__(self, provides: _Callable[..., T], *args: Injection, **kwargs: Injection) -> None: ... + def __init__(self, provides: Optional[_Callable[..., T]] = None, *args: Injection, **kwargs: Injection) -> None: ... @property def cls(self) -> T: ... @property def provides(self) -> T: ... + def set_provides(self, provides: Optional[_Callable[..., T]]) -> None: ... @property def args(self) -> Tuple[Injection]: ... def add_args(self, *args: Injection) -> Factory[T]: ... @@ -270,11 +272,12 @@ class FactoryAggregate(Provider): class BaseSingleton(Provider[T]): provided_type = Optional[Type] - def __init__(self, provides: _Callable[..., T], *args: Injection, **kwargs: Injection) -> None: ... + def __init__(self, provides: Optional[_Callable[..., T]] = None, *args: Injection, **kwargs: Injection) -> None: ... @property def cls(self) -> T: ... @property def provides(self) -> T: ... + def set_provides(self, provides: Optional[_Callable[..., T]]) -> None: ... @property def args(self) -> Tuple[Injection]: ... def add_args(self, *args: Injection) -> BaseSingleton[T]: ...