Add stub for the FactoryAggregate provider

This commit is contained in:
Roman Mogylatov 2020-08-26 16:52:07 -04:00
parent 2a609dd54b
commit 39923b3650
2 changed files with 17 additions and 0 deletions

View File

@ -188,6 +188,14 @@ class FactoryDelegate(Delegate):
def __init__(self, factory: Factory): ...
class FactoryAggregate(Provider):
def __init__(self, **factories: Factory): ...
def __call__(self, factory_name: str, *args: Injection, **kwargs: Injection) -> Any: ...
def __getattr__(self, factory_name: str) -> Factory: ...
@property
def factories(self) -> Dict[str, Factory]: ...
class ProvidedInstanceFluentInterface:
def __getattr__(self, item: str) -> AttributeGetter: ...
def __getitem__(self, item: str) -> ItemGetter: ...

View File

@ -53,3 +53,12 @@ animal7: Animal = provider7(1, 2, 3, b='1', c=2, e=0.0)
# Test 8: to check the FactoryDelegate __init__
provider8 = providers.FactoryDelegate(providers.Factory(object))
# Test 9: to check FactoryAggregate provider
provider9 = providers.FactoryAggregate(
a=providers.Factory(object),
b=providers.Factory(object),
)
factory_a_9: providers.Factory = provider9.a
factory_b_9: providers.Factory = provider9.b
val9: Any = provider9('a')