mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-09 06:43:13 +03:00
Add stubs for the DependenciesContainer provider
This commit is contained in:
parent
90c9c29c00
commit
94a2575ad4
|
@ -55,6 +55,13 @@ class Dependency(Provider, Generic[T]):
|
||||||
class ExternalDependency(Dependency): ...
|
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]):
|
class Callable(Provider, Generic[T]):
|
||||||
def __init__(self, provides: _Callable[..., T], *args: Injection, **kwargs: Injection) -> None: ...
|
def __init__(self, provides: _Callable[..., T], *args: Injection, **kwargs: Injection) -> None: ...
|
||||||
def __call__(self, *args: Injection, **kwargs: Injection) -> T: ...
|
def __call__(self, *args: Injection, **kwargs: Injection) -> T: ...
|
||||||
|
|
10
tests/typing/dependencies_container.py
Normal file
10
tests/typing/dependencies_container.py
Normal 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
|
Loading…
Reference in New Issue
Block a user