Make Provider stub generic and remove types module

This commit is contained in:
Roman Mogylatov 2020-09-13 12:06:28 -04:00
parent 7fc2f458a5
commit 2efefca7c0
3 changed files with 4 additions and 13 deletions

View File

@ -27,9 +27,9 @@ class OverridingContext:
def __exit__(self, *_: Any) -> None: ...
class Provider(_Provider):
class Provider(Generic[T]):
def __init__(self) -> None: ...
def __call__(self, *args: Injection, **kwargs: Injection) -> Any: ...
def __call__(self, *args: Injection, **kwargs: Injection) -> T: ...
def __deepcopy__(self, memo: Optional[Dict[str, Any]]) -> Provider: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...

View File

@ -1,9 +0,0 @@
from typing import TypeVar, Generic, Any
Injection = Any
T = TypeVar('T')
class Provider(Generic[T]):
def __call__(self, *args: Injection, **kwargs: Injection) -> T: ...

View File

@ -1,6 +1,6 @@
from typing import Tuple, Any, Dict
from dependency_injector import providers, types
from dependency_injector import providers
class Animal:
@ -64,5 +64,5 @@ factory_b_9: providers.Factory = provider9.b
val9: Any = provider9('a')
# Test 10: to check the explicit typing
factory10: types.Provider[Animal] = providers.Factory(Cat)
factory10: providers.Provider[Animal] = providers.Factory(Cat)
animal10: Animal = factory10()