mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-10-11 06:17:02 +03:00
Add stub for the declarative container
This commit is contained in:
parent
2152f259b7
commit
ce5d975126
|
@ -1,9 +1,9 @@
|
|||
from typing import Type, Dict, Tuple, Optional, Any, Union
|
||||
from typing import Type, Dict, Tuple, Optional, Any, Union, ClassVar, Callable as _Callable
|
||||
|
||||
from .providers import Provider
|
||||
|
||||
|
||||
class DynamicContainer:
|
||||
class Container:
|
||||
provider_type: Type[Provider] = Provider
|
||||
providers: Dict[str, Provider]
|
||||
overridden: Tuple[Provider]
|
||||
|
@ -16,3 +16,19 @@ class DynamicContainer:
|
|||
def override_providers(self, **overriding_providers: Provider) -> None: ...
|
||||
def reset_last_overriding(self) -> None: ...
|
||||
def reset_override(self) -> None: ...
|
||||
|
||||
|
||||
class DynamicContainer(Container): ...
|
||||
|
||||
|
||||
class DeclarativeContainer(Container):
|
||||
cls_providers: ClassVar[Dict[str, Provider]]
|
||||
inherited_providers: ClassVar[Dict[str, Provider]]
|
||||
|
||||
|
||||
def override(container: Container) -> _Callable[[Container], Container]: ...
|
||||
|
||||
|
||||
def copy(container: Container) -> _Callable[[Container], Container]: ...
|
||||
|
||||
def is_container(instance: Any) -> bool: ...
|
||||
|
|
12
tests/typing/declarative_container.py
Normal file
12
tests/typing/declarative_container.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from dependency_injector import containers, providers
|
||||
|
||||
|
||||
# Test 1: to check declarative container subclass
|
||||
class Container1(containers.DeclarativeContainer):
|
||||
provider = providers.Factory(int)
|
||||
|
||||
|
||||
container1 = Container1()
|
||||
container1_type: containers.Container = Container1()
|
||||
provider1: providers.Provider = container1.provider
|
||||
val1: int = container1.provider(3)
|
Loading…
Reference in New Issue
Block a user