Add stubs for the DependenciesContainer provider

This commit is contained in:
Roman Mogylatov 2020-08-25 16:53:33 -04:00
parent 90c9c29c00
commit 94a2575ad4
2 changed files with 17 additions and 0 deletions

View File

@ -55,6 +55,13 @@ class Dependency(Provider, Generic[T]):
class ExternalDependency(Dependency): ...
class DependenciesContainer(Object):
def __init__(self, **dependencies: Provider) -> None: ...
def __getattr__(self, name: str) -> Provider: ...
@property
def providers(self) -> Dict[str, Provider]: ...
class Callable(Provider, Generic[T]):
def __init__(self, provides: _Callable[..., T], *args: Injection, **kwargs: Injection) -> None: ...
def __call__(self, *args: Injection, **kwargs: Injection) -> T: ...

View File

@ -0,0 +1,10 @@
from dependency_injector import providers
# Test 1: to check the getattr type
provider1 = providers.DependenciesContainer(
a=providers.Provider(),
b=providers.Provider(),
)
a1: providers.Provider = provider1.a
b1: providers.Provider = provider1.b