mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-09 06:43:13 +03:00
Remove typing module
This commit is contained in:
parent
0f525dbac0
commit
8f7b466de9
|
@ -1 +1,119 @@
|
||||||
from .types import *
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TypeVar, Generic, Type, Callable as _Callable, Any, Tuple, Optional, Dict, Union
|
||||||
|
|
||||||
|
Injection = Any
|
||||||
|
T = TypeVar('T')
|
||||||
|
|
||||||
|
|
||||||
|
class OverridingContext:
|
||||||
|
def __init__(self, overridden: Provider, overriding: Provider): ...
|
||||||
|
def __enter__(self) -> Provider: ...
|
||||||
|
def __exit__(self, *_: Any) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
|
class Provider:
|
||||||
|
def __init__(self) -> None: ...
|
||||||
|
def __call__(self, *args: Injection, **kwargs: Injection) -> Any: ...
|
||||||
|
def __deepcopy__(self, memo: Optional[Dict[str, Any]]) -> Provider: ...
|
||||||
|
def __str__(self) -> str: ...
|
||||||
|
def __repr__(self) -> str: ...
|
||||||
|
@property
|
||||||
|
def overridden(self) -> Tuple[Provider]: ...
|
||||||
|
@property
|
||||||
|
def last_overriding(self) -> Optional[Provider]: ...
|
||||||
|
def override(self, provider: Union[Provider, Any]) -> OverridingContext: ...
|
||||||
|
def reset_last_overriding(self) -> None: ...
|
||||||
|
def reset_override(self) -> None: ...
|
||||||
|
def delegate(self) -> Provider: ...
|
||||||
|
@property
|
||||||
|
def provider(self) -> Provider: ...
|
||||||
|
|
||||||
|
|
||||||
|
class Object(Provider, Generic[T]):
|
||||||
|
def __init__(self, provides: T) -> None: ...
|
||||||
|
def __call__(self, *args: Injection, **kwargs: Injection) -> T: ...
|
||||||
|
@property
|
||||||
|
def provided(self) -> ProvidedInstance: ...
|
||||||
|
|
||||||
|
|
||||||
|
class Callable(Provider, Generic[T]):
|
||||||
|
def __init__(self, provides: _Callable[..., T], *args: Injection, **kwargs: Injection) -> None: ...
|
||||||
|
def __call__(self, *args: Injection, **kwargs: Injection) -> T: ...
|
||||||
|
@property
|
||||||
|
def provides(self) -> T: ...
|
||||||
|
@property
|
||||||
|
def provided(self) -> ProvidedInstance: ...
|
||||||
|
@property
|
||||||
|
def args(self) -> Tuple[Injection]: ...
|
||||||
|
def add_args(self, *args: Injection) -> Callable[T]: ...
|
||||||
|
def set_args(self, *args: Injection) -> Callable[T]: ...
|
||||||
|
def clear_args(self) -> Callable[T]: ...
|
||||||
|
@property
|
||||||
|
def kwargs(self) -> Dict[str, Injection]: ...
|
||||||
|
def add_kwargs(self, **kwargs: Injection) -> Callable[T]: ...
|
||||||
|
def set_kwargs(self, **kwargs: Injection) -> Callable[T]: ...
|
||||||
|
def clear_kwargs(self) -> Callable[T]: ...
|
||||||
|
|
||||||
|
|
||||||
|
class DelegatedCallable(Callable): ...
|
||||||
|
|
||||||
|
|
||||||
|
class AbstractCallable(Callable):
|
||||||
|
def override(self, provider: Callable) -> OverridingContext: ...
|
||||||
|
|
||||||
|
|
||||||
|
class Factory(Provider, Generic[T]):
|
||||||
|
provided_type: Optional[Type]
|
||||||
|
def __init__(self, provides: _Callable[..., T], *args: Injection, **kwargs: Injection) -> None: ...
|
||||||
|
def __call__(self, *args: Injection, **kwargs: Injection) -> T: ...
|
||||||
|
@property
|
||||||
|
def cls(self) -> T: ...
|
||||||
|
@property
|
||||||
|
def provides(self) -> T: ...
|
||||||
|
@property
|
||||||
|
def provided(self) -> ProvidedInstance: ...
|
||||||
|
@property
|
||||||
|
def args(self) -> Tuple[Injection]: ...
|
||||||
|
def add_args(self, *args: Injection) -> Factory[T]: ...
|
||||||
|
def set_args(self, *args: Injection) -> Factory[T]: ...
|
||||||
|
def clear_args(self) -> Factory[T]: ...
|
||||||
|
@property
|
||||||
|
def kwargs(self) -> Dict[str, Injection]: ...
|
||||||
|
def add_kwargs(self, **kwargs: Injection) -> Factory[T]: ...
|
||||||
|
def set_kwargs(self, **kwargs: Injection) -> Factory[T]: ...
|
||||||
|
def clear_kwargs(self) -> Factory[T]: ...
|
||||||
|
@property
|
||||||
|
def attributes(self) -> Dict[str, Injection]: ...
|
||||||
|
def add_attributes(self, **kwargs: Injection) -> Factory[T]: ...
|
||||||
|
def set_attributes(self, **kwargs: Injection) -> Factory[T]: ...
|
||||||
|
def clear_attributes(self) -> Factory[T]: ...
|
||||||
|
|
||||||
|
|
||||||
|
class DelegatedFactory(Factory): ...
|
||||||
|
|
||||||
|
|
||||||
|
class AbstractFactory(Factory):
|
||||||
|
def override(self, provider: Factory) -> OverridingContext: ...
|
||||||
|
|
||||||
|
|
||||||
|
class ProvidedInstanceFluentInterface:
|
||||||
|
def __getattr__(self, item: str) -> AttributeGetter: ...
|
||||||
|
def __getitem__(self, item: str) -> ItemGetter: ...
|
||||||
|
def call(self, *args: Injection, **kwargs: Injection) -> MethodCaller: ...
|
||||||
|
|
||||||
|
|
||||||
|
class ProvidedInstance(Provider, ProvidedInstanceFluentInterface):
|
||||||
|
def __init__(self, provider: Provider) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
|
class AttributeGetter(Provider, ProvidedInstanceFluentInterface):
|
||||||
|
def __init__(self, provider: Provider, attribute: str) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
|
class ItemGetter(Provider, ProvidedInstanceFluentInterface):
|
||||||
|
def __init__(self, provider: Provider, item: str) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
|
class MethodCaller(Provider, ProvidedInstanceFluentInterface):
|
||||||
|
def __init__(self, provider: Provider, *args: Injection, **kwargs: Injection) -> None: ...
|
||||||
|
|
|
@ -1,119 +0,0 @@
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from typing import TypeVar, Generic, Type, Callable as _Callable, Any, Tuple, Optional, Dict, Union
|
|
||||||
|
|
||||||
Injection = Any
|
|
||||||
T = TypeVar('T')
|
|
||||||
|
|
||||||
|
|
||||||
class OverridingContext:
|
|
||||||
def __init__(self, overridden: Provider, overriding: Provider): ...
|
|
||||||
def __enter__(self) -> Provider: ...
|
|
||||||
def __exit__(self, *_: Any) -> None: ...
|
|
||||||
|
|
||||||
|
|
||||||
class Provider:
|
|
||||||
def __init__(self) -> None: ...
|
|
||||||
def __call__(self, *args: Injection, **kwargs: Injection) -> Any: ...
|
|
||||||
def __deepcopy__(self, memo: Optional[Dict[str, Any]]) -> Provider: ...
|
|
||||||
def __str__(self) -> str: ...
|
|
||||||
def __repr__(self) -> str: ...
|
|
||||||
@property
|
|
||||||
def overridden(self) -> Tuple[Provider]: ...
|
|
||||||
@property
|
|
||||||
def last_overriding(self) -> Optional[Provider]: ...
|
|
||||||
def override(self, provider: Union[Provider, Any]) -> OverridingContext: ...
|
|
||||||
def reset_last_overriding(self) -> None: ...
|
|
||||||
def reset_override(self) -> None: ...
|
|
||||||
def delegate(self) -> Provider: ...
|
|
||||||
@property
|
|
||||||
def provider(self) -> Provider: ...
|
|
||||||
|
|
||||||
|
|
||||||
class Object(Provider, Generic[T]):
|
|
||||||
def __init__(self, provides: T) -> None: ...
|
|
||||||
def __call__(self, *args: Injection, **kwargs: Injection) -> T: ...
|
|
||||||
@property
|
|
||||||
def provided(self) -> ProvidedInstance: ...
|
|
||||||
|
|
||||||
|
|
||||||
class Callable(Provider, Generic[T]):
|
|
||||||
def __init__(self, provides: _Callable[..., T], *args: Injection, **kwargs: Injection) -> None: ...
|
|
||||||
def __call__(self, *args: Injection, **kwargs: Injection) -> T: ...
|
|
||||||
@property
|
|
||||||
def provides(self) -> T: ...
|
|
||||||
@property
|
|
||||||
def provided(self) -> ProvidedInstance: ...
|
|
||||||
@property
|
|
||||||
def args(self) -> Tuple[Injection]: ...
|
|
||||||
def add_args(self, *args: Injection) -> Callable[T]: ...
|
|
||||||
def set_args(self, *args: Injection) -> Callable[T]: ...
|
|
||||||
def clear_args(self) -> Callable[T]: ...
|
|
||||||
@property
|
|
||||||
def kwargs(self) -> Dict[str, Injection]: ...
|
|
||||||
def add_kwargs(self, **kwargs: Injection) -> Callable[T]: ...
|
|
||||||
def set_kwargs(self, **kwargs: Injection) -> Callable[T]: ...
|
|
||||||
def clear_kwargs(self) -> Callable[T]: ...
|
|
||||||
|
|
||||||
|
|
||||||
class DelegatedCallable(Callable): ...
|
|
||||||
|
|
||||||
|
|
||||||
class AbstractCallable(Callable):
|
|
||||||
def override(self, provider: Callable) -> OverridingContext: ...
|
|
||||||
|
|
||||||
|
|
||||||
class Factory(Provider, Generic[T]):
|
|
||||||
provided_type: Optional[Type]
|
|
||||||
def __init__(self, provides: _Callable[..., T], *args: Injection, **kwargs: Injection) -> None: ...
|
|
||||||
def __call__(self, *args: Injection, **kwargs: Injection) -> T: ...
|
|
||||||
@property
|
|
||||||
def cls(self) -> T: ...
|
|
||||||
@property
|
|
||||||
def provides(self) -> T: ...
|
|
||||||
@property
|
|
||||||
def provided(self) -> ProvidedInstance: ...
|
|
||||||
@property
|
|
||||||
def args(self) -> Tuple[Injection]: ...
|
|
||||||
def add_args(self, *args: Injection) -> Factory[T]: ...
|
|
||||||
def set_args(self, *args: Injection) -> Factory[T]: ...
|
|
||||||
def clear_args(self) -> Factory[T]: ...
|
|
||||||
@property
|
|
||||||
def kwargs(self) -> Dict[str, Injection]: ...
|
|
||||||
def add_kwargs(self, **kwargs: Injection) -> Factory[T]: ...
|
|
||||||
def set_kwargs(self, **kwargs: Injection) -> Factory[T]: ...
|
|
||||||
def clear_kwargs(self) -> Factory[T]: ...
|
|
||||||
@property
|
|
||||||
def attributes(self) -> Dict[str, Injection]: ...
|
|
||||||
def add_attributes(self, **kwargs: Injection) -> Factory[T]: ...
|
|
||||||
def set_attributes(self, **kwargs: Injection) -> Factory[T]: ...
|
|
||||||
def clear_attributes(self) -> Factory[T]: ...
|
|
||||||
|
|
||||||
|
|
||||||
class DelegatedFactory(Factory): ...
|
|
||||||
|
|
||||||
|
|
||||||
class AbstractFactory(Factory):
|
|
||||||
def override(self, provider: Factory) -> OverridingContext: ...
|
|
||||||
|
|
||||||
|
|
||||||
class ProvidedInstanceFluentInterface:
|
|
||||||
def __getattr__(self, item: str) -> AttributeGetter: ...
|
|
||||||
def __getitem__(self, item: str) -> ItemGetter: ...
|
|
||||||
def call(self, *args: Injection, **kwargs: Injection) -> MethodCaller: ...
|
|
||||||
|
|
||||||
|
|
||||||
class ProvidedInstance(Provider, ProvidedInstanceFluentInterface):
|
|
||||||
def __init__(self, provider: Provider) -> None: ...
|
|
||||||
|
|
||||||
|
|
||||||
class AttributeGetter(Provider, ProvidedInstanceFluentInterface):
|
|
||||||
def __init__(self, provider: Provider, attribute: str) -> None: ...
|
|
||||||
|
|
||||||
|
|
||||||
class ItemGetter(Provider, ProvidedInstanceFluentInterface):
|
|
||||||
def __init__(self, provider: Provider, item: str) -> None: ...
|
|
||||||
|
|
||||||
|
|
||||||
class MethodCaller(Provider, ProvidedInstanceFluentInterface):
|
|
||||||
def __init__(self, provider: Provider, *args: Injection, **kwargs: Injection) -> None: ...
|
|
|
@ -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:
|
||||||
|
@ -51,7 +51,3 @@ animal6: Animal = provider6(1, 2, 3, b='1', c=2, e=0.0)
|
||||||
provider7 = providers.AbstractFactory(Animal)
|
provider7 = providers.AbstractFactory(Animal)
|
||||||
provider7.override(providers.Factory(Cat))
|
provider7.override(providers.Factory(Cat))
|
||||||
animal7: Animal = provider7(1, 2, 3, b='1', c=2, e=0.0)
|
animal7: Animal = provider7(1, 2, 3, b='1', c=2, e=0.0)
|
||||||
|
|
||||||
# Test 8: to check the explicit typing
|
|
||||||
provider8: types.Factory[Animal] = providers.Factory(Cat)
|
|
||||||
animal8: Animal = provider8()
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user