Add stub for the Container provider

This commit is contained in:
Roman Mogylatov 2020-08-26 17:53:11 -04:00
parent 5100f13bff
commit ce412980d2
2 changed files with 21 additions and 0 deletions

View File

@ -261,6 +261,13 @@ class List(Provider):
def clear_args(self) -> List: ...
class Container(Provider):
def __init__(self, container_cls: Type[T], container: Optional[T] = None, **overriding_providers: Provider) -> None: ...
def __call__(self, *args: Injection, **kwargs: Injection) -> T: ...
def __getattr__(self, name: str) -> Provider: ...
class ProvidedInstanceFluentInterface:
def __getattr__(self, item: str) -> AttributeGetter: ...
def __getitem__(self, item: str) -> ItemGetter: ...

14
tests/typing/container.py Normal file
View File

@ -0,0 +1,14 @@
from dependency_injector import providers
class Container:
...
# Test 1: to check the return type
provider1 = providers.Container(Container)
var1: Container = provider1()
# Test 2: to check the getattr
provider2 = providers.Container(Container)
attr: providers.Provider = provider2.attr