mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-05-23 14:59:08 +03:00
Make Provider stub generic and remove types module
This commit is contained in:
parent
7fc2f458a5
commit
2efefca7c0
|
@ -27,9 +27,9 @@ class OverridingContext:
|
||||||
def __exit__(self, *_: Any) -> None: ...
|
def __exit__(self, *_: Any) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
class Provider(_Provider):
|
class Provider(Generic[T]):
|
||||||
def __init__(self) -> None: ...
|
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 __deepcopy__(self, memo: Optional[Dict[str, Any]]) -> Provider: ...
|
||||||
def __str__(self) -> str: ...
|
def __str__(self) -> str: ...
|
||||||
def __repr__(self) -> str: ...
|
def __repr__(self) -> str: ...
|
||||||
|
|
|
@ -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: ...
|
|
|
@ -1,6 +1,6 @@
|
||||||
from typing import Tuple, Any, Dict
|
from typing import Tuple, Any, Dict
|
||||||
|
|
||||||
from dependency_injector import providers, types
|
from dependency_injector import providers
|
||||||
|
|
||||||
|
|
||||||
class Animal:
|
class Animal:
|
||||||
|
@ -64,5 +64,5 @@ factory_b_9: providers.Factory = provider9.b
|
||||||
val9: Any = provider9('a')
|
val9: Any = provider9('a')
|
||||||
|
|
||||||
# Test 10: to check the explicit typing
|
# Test 10: to check the explicit typing
|
||||||
factory10: types.Provider[Animal] = providers.Factory(Cat)
|
factory10: providers.Provider[Animal] = providers.Factory(Cat)
|
||||||
animal10: Animal = factory10()
|
animal10: Animal = factory10()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user