2020-08-27 05:24:20 +03:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2020-10-16 20:57:28 +03:00
|
|
|
from pathlib import Path
|
2020-08-27 05:24:20 +03:00
|
|
|
from typing import (
|
2021-01-11 03:26:15 +03:00
|
|
|
Awaitable,
|
2020-08-27 05:24:20 +03:00
|
|
|
TypeVar,
|
|
|
|
Generic,
|
|
|
|
Type,
|
|
|
|
Callable as _Callable,
|
|
|
|
Any,
|
|
|
|
Tuple,
|
|
|
|
List as _List,
|
2020-10-22 21:49:39 +03:00
|
|
|
Dict as _Dict,
|
2020-08-27 05:24:20 +03:00
|
|
|
Optional,
|
|
|
|
Union,
|
|
|
|
Coroutine as _Coroutine,
|
2021-02-01 17:42:21 +03:00
|
|
|
Iterable as _Iterable,
|
2020-10-25 03:56:32 +03:00
|
|
|
Iterator as _Iterator,
|
2021-01-11 03:26:15 +03:00
|
|
|
AsyncIterator as _AsyncIterator,
|
2020-10-25 03:56:32 +03:00
|
|
|
Generator as _Generator,
|
|
|
|
overload,
|
2020-08-27 05:24:20 +03:00
|
|
|
)
|
|
|
|
|
2021-01-22 02:00:24 +03:00
|
|
|
try:
|
|
|
|
import yaml
|
|
|
|
except ImportError:
|
|
|
|
yaml = None
|
|
|
|
|
2021-02-03 17:21:32 +03:00
|
|
|
try:
|
|
|
|
import pydantic
|
|
|
|
except ImportError:
|
|
|
|
pydantic = None
|
|
|
|
|
2020-10-25 03:56:32 +03:00
|
|
|
from . import resources
|
|
|
|
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
Injection = Any
|
2022-01-17 03:46:18 +03:00
|
|
|
ProviderParent = Union["Provider", Any]
|
|
|
|
T = TypeVar("T")
|
|
|
|
TT = TypeVar("TT")
|
|
|
|
P = TypeVar("P", bound="Provider")
|
|
|
|
BS = TypeVar("BS", bound="BaseSingleton")
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2020-09-14 03:32:21 +03:00
|
|
|
class Provider(Generic[T]):
|
2020-08-27 05:24:20 +03:00
|
|
|
def __init__(self) -> None: ...
|
2021-01-11 03:26:15 +03:00
|
|
|
|
|
|
|
@overload
|
2020-09-14 03:32:21 +03:00
|
|
|
def __call__(self, *args: Injection, **kwargs: Injection) -> T: ...
|
2021-01-11 03:26:15 +03:00
|
|
|
@overload
|
|
|
|
def __call__(self, *args: Injection, **kwargs: Injection) -> Awaitable[T]: ...
|
|
|
|
def async_(self, *args: Injection, **kwargs: Injection) -> Awaitable[T]: ...
|
|
|
|
|
2020-10-22 21:49:39 +03:00
|
|
|
def __deepcopy__(self, memo: Optional[_Dict[Any, Any]]) -> Provider: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
def __str__(self) -> str: ...
|
|
|
|
def __repr__(self) -> str: ...
|
|
|
|
@property
|
|
|
|
def overridden(self) -> Tuple[Provider]: ...
|
|
|
|
@property
|
|
|
|
def last_overriding(self) -> Optional[Provider]: ...
|
2021-03-03 16:28:10 +03:00
|
|
|
def override(self, provider: Union[Provider, Any]) -> OverridingContext[P]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
def reset_last_overriding(self) -> None: ...
|
|
|
|
def reset_override(self) -> None: ...
|
2021-03-21 04:41:39 +03:00
|
|
|
@property
|
|
|
|
def overrides(self) -> Tuple[Provider]: ...
|
|
|
|
def register_overrides(self, provider: Union[Provider, Any]) -> None: ...
|
|
|
|
def unregister_overrides(self, provider: Union[Provider, Any]) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
def delegate(self) -> Provider: ...
|
|
|
|
@property
|
|
|
|
def provider(self) -> Provider: ...
|
2020-10-20 00:21:38 +03:00
|
|
|
@property
|
|
|
|
def provided(self) -> ProvidedInstance: ...
|
2021-01-11 03:26:15 +03:00
|
|
|
def enable_async_mode(self) -> None: ...
|
|
|
|
def disable_async_mode(self) -> None: ...
|
|
|
|
def reset_async_mode(self) -> None: ...
|
|
|
|
def is_async_mode_enabled(self) -> bool: ...
|
|
|
|
def is_async_mode_disabled(self) -> bool: ...
|
|
|
|
def is_async_mode_undefined(self) -> bool: ...
|
2021-02-01 17:42:21 +03:00
|
|
|
@property
|
|
|
|
def related(self) -> _Iterator[Provider]: ...
|
2021-02-07 22:13:23 +03:00
|
|
|
def traverse(self, types: Optional[_Iterable[Type[TT]]] = None) -> _Iterator[TT]: ...
|
2020-10-22 21:49:39 +03:00
|
|
|
def _copy_overridings(self, copied: Provider, memo: Optional[_Dict[Any, Any]]) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class Object(Provider[T]):
|
2021-03-20 20:16:51 +03:00
|
|
|
def __init__(self, provides: Optional[T] = None) -> None: ...
|
2021-08-24 04:24:36 +03:00
|
|
|
@property
|
2021-03-20 20:16:51 +03:00
|
|
|
def provides(self) -> Optional[T]: ...
|
|
|
|
def set_provides(self, provides: Optional[T]) -> Object: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-02-07 22:13:23 +03:00
|
|
|
class Self(Provider[T]):
|
|
|
|
def __init__(self, container: Optional[T] = None) -> None: ...
|
|
|
|
def set_container(self, container: T) -> None: ...
|
|
|
|
def set_alt_names(self, alt_names: _Iterable[Any]) -> None: ...
|
|
|
|
@property
|
|
|
|
def alt_names(self) -> Tuple[Any]: ...
|
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class Delegate(Provider[Provider]):
|
2021-03-06 01:24:48 +03:00
|
|
|
def __init__(self, provides: Optional[Provider] = None) -> None: ...
|
2020-10-09 22:16:27 +03:00
|
|
|
@property
|
2021-03-06 01:24:48 +03:00
|
|
|
def provides(self) -> Optional[Provider]: ...
|
2021-03-20 20:16:51 +03:00
|
|
|
def set_provides(self, provides: Optional[Provider]) -> Delegate: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2022-01-10 05:45:20 +03:00
|
|
|
class Aggregate(Provider[T]):
|
|
|
|
def __init__(self, provider_dict: Optional[_Dict[Any, Provider[T]]] = None, **provider_kwargs: Provider[T]): ...
|
|
|
|
def __getattr__(self, provider_name: Any) -> Provider[T]: ...
|
|
|
|
|
|
|
|
@overload
|
|
|
|
def __call__(self, provider_name: Optional[Any] = None, *args: Injection, **kwargs: Injection) -> T: ...
|
|
|
|
@overload
|
|
|
|
def __call__(self, provider_name: Optional[Any] = None, *args: Injection, **kwargs: Injection) -> Awaitable[T]: ...
|
|
|
|
def async_(self, provider_name: Optional[Any] = None, *args: Injection, **kwargs: Injection) -> Awaitable[T]: ...
|
|
|
|
|
|
|
|
@property
|
|
|
|
def providers(self) -> _Dict[Any, Provider[T]]: ...
|
|
|
|
def set_providers(self, provider_dict: Optional[_Dict[Any, Provider[T]]] = None, **provider_kwargs: Provider[T]) -> Aggregate[T]: ...
|
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class Dependency(Provider[T]):
|
2021-01-29 21:49:40 +03:00
|
|
|
def __init__(self, instance_of: Type[T] = object, default: Optional[Union[Provider, Any]] = None) -> None: ...
|
2021-02-19 01:49:23 +03:00
|
|
|
def __getattr__(self, name: str) -> Any: ...
|
2021-03-20 20:16:51 +03:00
|
|
|
|
2020-08-27 05:24:20 +03:00
|
|
|
@property
|
|
|
|
def instance_of(self) -> Type[T]: ...
|
2021-03-20 20:16:51 +03:00
|
|
|
def set_instance_of(self, instance_of: Type[T]) -> Dependency[T]: ...
|
|
|
|
|
2021-01-29 21:49:40 +03:00
|
|
|
@property
|
|
|
|
def default(self) -> Provider[T]: ...
|
2021-03-20 20:16:51 +03:00
|
|
|
def set_default(self, default: Optional[Union[Provider, Any]]) -> Dependency[T]: ...
|
|
|
|
|
2021-02-15 02:47:15 +03:00
|
|
|
@property
|
|
|
|
def is_defined(self) -> bool: ...
|
2021-03-03 16:28:10 +03:00
|
|
|
def provided_by(self, provider: Provider) -> OverridingContext[P]: ...
|
2021-02-13 17:16:38 +03:00
|
|
|
@property
|
|
|
|
def parent(self) -> Optional[ProviderParent]: ...
|
|
|
|
@property
|
|
|
|
def parent_name(self) -> Optional[str]: ...
|
|
|
|
def assign_parent(self, parent: ProviderParent) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class ExternalDependency(Dependency[T]): ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
class DependenciesContainer(Object):
|
|
|
|
def __init__(self, **dependencies: Provider) -> None: ...
|
|
|
|
def __getattr__(self, name: str) -> Provider: ...
|
|
|
|
@property
|
2020-10-22 21:49:39 +03:00
|
|
|
def providers(self) -> _Dict[str, Provider]: ...
|
2021-02-13 17:16:38 +03:00
|
|
|
def resolve_provider_name(self, provider: Provider) -> str: ...
|
|
|
|
@property
|
|
|
|
def parent(self) -> Optional[ProviderParent]: ...
|
|
|
|
@property
|
|
|
|
def parent_name(self) -> Optional[str]: ...
|
|
|
|
def assign_parent(self, parent: ProviderParent) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class Callable(Provider[T]):
|
2022-01-31 07:16:55 +03:00
|
|
|
def __init__(self, provides: Optional[Union[_Callable[..., T], str]] = None, *args: Injection, **kwargs: Injection) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
@property
|
2021-08-24 04:24:36 +03:00
|
|
|
def provides(self) -> Optional[_Callable[..., T]]: ...
|
2022-01-31 07:16:55 +03:00
|
|
|
def set_provides(self, provides: Optional[Union[_Callable[..., T], str]]) -> Callable[T]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
@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
|
2021-01-11 03:26:15 +03:00
|
|
|
def kwargs(self) -> _Dict[Any, Injection]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
def add_kwargs(self, **kwargs: Injection) -> Callable[T]: ...
|
|
|
|
def set_kwargs(self, **kwargs: Injection) -> Callable[T]: ...
|
|
|
|
def clear_kwargs(self) -> Callable[T]: ...
|
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class DelegatedCallable(Callable[T]): ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class AbstractCallable(Callable[T]):
|
2021-03-03 16:28:10 +03:00
|
|
|
def override(self, provider: Callable) -> OverridingContext[P]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
class CallableDelegate(Delegate):
|
|
|
|
def __init__(self, callable: Callable) -> None: ...
|
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class Coroutine(Callable[T]): ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class DelegatedCoroutine(Coroutine[T]): ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class AbstractCoroutine(Coroutine[T]):
|
2021-03-03 16:28:10 +03:00
|
|
|
def override(self, provider: Coroutine) -> OverridingContext[P]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
class CoroutineDelegate(Delegate):
|
|
|
|
def __init__(self, coroutine: Coroutine) -> None: ...
|
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class ConfigurationOption(Provider[Any]):
|
2020-08-27 05:24:20 +03:00
|
|
|
UNDEFINED: object
|
2020-10-09 22:16:27 +03:00
|
|
|
def __init__(self, name: Tuple[str], root: Configuration) -> None: ...
|
2021-02-15 17:11:39 +03:00
|
|
|
def __enter__(self) -> ConfigurationOption: ...
|
|
|
|
def __exit__(self, *exc_info: Any) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
def __getattr__(self, item: str) -> ConfigurationOption: ...
|
2020-10-09 22:16:27 +03:00
|
|
|
def __getitem__(self, item: Union[str, Provider]) -> ConfigurationOption: ...
|
|
|
|
@property
|
|
|
|
def root(self) -> Configuration: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
def get_name(self) -> str: ...
|
2020-10-09 22:16:27 +03:00
|
|
|
def get_name_segments(self) -> Tuple[Union[str, Provider]]: ...
|
|
|
|
def as_int(self) -> TypedConfigurationOption[int]: ...
|
|
|
|
def as_float(self) -> TypedConfigurationOption[float]: ...
|
|
|
|
def as_(self, callback: _Callable[..., T], *args: Injection, **kwargs: Injection) -> TypedConfigurationOption[T]: ...
|
2021-01-16 16:53:40 +03:00
|
|
|
def required(self) -> ConfigurationOption: ...
|
|
|
|
def is_required(self) -> bool: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
def update(self, value: Any) -> None: ...
|
2021-06-24 16:00:36 +03:00
|
|
|
def from_ini(self, filepath: Union[Path, str], required: bool = False, envs_required: bool = False) -> None: ...
|
|
|
|
def from_yaml(self, filepath: Union[Path, str], required: bool = False, loader: Optional[Any] = None, envs_required: bool = False) -> None: ...
|
2022-07-10 04:41:29 +03:00
|
|
|
def from_json(self, filepath: Union[Path, str], required: bool = False, envs_required: bool = False) -> None: ...
|
2021-02-03 17:21:32 +03:00
|
|
|
def from_pydantic(self, settings: PydanticSettings, required: bool = False, **kwargs: Any) -> None: ...
|
2021-01-24 18:27:45 +03:00
|
|
|
def from_dict(self, options: _Dict[str, Any], required: bool = False) -> None: ...
|
2021-12-21 01:46:51 +03:00
|
|
|
def from_env(self, name: str, default: Optional[Any] = None, required: bool = False, as_: Optional[_Callable[..., Any]] = None) -> None: ...
|
2021-06-14 05:05:29 +03:00
|
|
|
def from_value(self, value: Any) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2020-10-09 22:16:27 +03:00
|
|
|
class TypedConfigurationOption(Callable[T]):
|
|
|
|
@property
|
|
|
|
def option(self) -> ConfigurationOption: ...
|
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class Configuration(Object[Any]):
|
2022-01-17 03:46:18 +03:00
|
|
|
DEFAULT_NAME: str = "config"
|
2021-10-27 03:27:11 +03:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
name: str = DEFAULT_NAME,
|
|
|
|
default: Optional[Any] = None,
|
|
|
|
*,
|
|
|
|
strict: bool = False,
|
|
|
|
ini_files: Optional[_Iterable[Union[Path, str]]] = None,
|
2022-07-10 05:20:15 +03:00
|
|
|
yaml_files: Optional[_Iterable[Union[Path, str]]] = None,
|
|
|
|
json_files: Optional[_Iterable[Union[Path, str]]] = None,
|
2021-10-27 04:08:47 +03:00
|
|
|
pydantic_settings: Optional[_Iterable[PydanticSettings]] = None,
|
2021-10-27 03:27:11 +03:00
|
|
|
) -> None: ...
|
2021-02-15 17:11:39 +03:00
|
|
|
def __enter__(self) -> Configuration : ...
|
|
|
|
def __exit__(self, *exc_info: Any) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
def __getattr__(self, item: str) -> ConfigurationOption: ...
|
2020-10-09 22:16:27 +03:00
|
|
|
def __getitem__(self, item: Union[str, Provider]) -> ConfigurationOption: ...
|
2021-03-20 20:16:51 +03:00
|
|
|
|
2020-08-27 05:24:20 +03:00
|
|
|
def get_name(self) -> str: ...
|
2021-03-20 20:16:51 +03:00
|
|
|
def set_name(self, name: str) -> Configuration: ...
|
|
|
|
|
|
|
|
def get_default(self) -> _Dict[Any, Any]: ...
|
|
|
|
def set_default(self, default: _Dict[Any, Any]): ...
|
|
|
|
|
|
|
|
def get_strict(self) -> bool: ...
|
|
|
|
def set_strict(self, strict: bool) -> Configuration: ...
|
|
|
|
|
|
|
|
def get_children(self) -> _Dict[str, ConfigurationOption]: ...
|
|
|
|
def set_children(self, children: _Dict[str, ConfigurationOption]) -> Configuration: ...
|
|
|
|
|
2022-07-10 05:20:15 +03:00
|
|
|
def get_ini_files(self) -> _List[Union[Path, str]]: ...
|
|
|
|
def set_ini_files(self, files: _Iterable[Union[Path, str]]) -> Configuration: ...
|
|
|
|
|
2021-10-24 04:46:50 +03:00
|
|
|
def get_yaml_files(self) -> _List[Union[Path, str]]: ...
|
|
|
|
def set_yaml_files(self, files: _Iterable[Union[Path, str]]) -> Configuration: ...
|
|
|
|
|
2022-07-10 05:20:15 +03:00
|
|
|
def get_json_files(self) -> _List[Union[Path, str]]: ...
|
|
|
|
def set_json_files(self, files: _Iterable[Union[Path, str]]) -> Configuration: ...
|
2021-10-27 03:27:11 +03:00
|
|
|
|
2021-10-27 04:08:47 +03:00
|
|
|
def get_pydantic_settings(self) -> _List[PydanticSettings]: ...
|
|
|
|
def set_pydantic_settings(self, settings: _Iterable[PydanticSettings]) -> Configuration: ...
|
|
|
|
|
2021-10-24 04:46:50 +03:00
|
|
|
def load(self, required: bool = False, envs_required: bool = False) -> None: ...
|
|
|
|
|
2020-08-27 05:24:20 +03:00
|
|
|
def get(self, selector: str) -> Any: ...
|
2021-03-03 16:28:10 +03:00
|
|
|
def set(self, selector: str, value: Any) -> OverridingContext[P]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
def reset_cache(self) -> None: ...
|
|
|
|
def update(self, value: Any) -> None: ...
|
2021-06-24 16:00:36 +03:00
|
|
|
def from_ini(self, filepath: Union[Path, str], required: bool = False, envs_required: bool = False) -> None: ...
|
|
|
|
def from_yaml(self, filepath: Union[Path, str], required: bool = False, loader: Optional[Any] = None, envs_required: bool = False) -> None: ...
|
2022-07-10 04:41:29 +03:00
|
|
|
def from_json(self, filepath: Union[Path, str], required: bool = False, envs_required: bool = False) -> None: ...
|
2021-02-03 17:21:32 +03:00
|
|
|
def from_pydantic(self, settings: PydanticSettings, required: bool = False, **kwargs: Any) -> None: ...
|
2021-01-24 18:27:45 +03:00
|
|
|
def from_dict(self, options: _Dict[str, Any], required: bool = False) -> None: ...
|
2021-12-21 01:46:51 +03:00
|
|
|
def from_env(self, name: str, default: Optional[Any] = None, required: bool = False, as_: Optional[_Callable[..., Any]] = None) -> None: ...
|
2021-06-14 05:05:29 +03:00
|
|
|
def from_value(self, value: Any) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class Factory(Provider[T]):
|
2020-08-27 05:24:20 +03:00
|
|
|
provided_type: Optional[Type]
|
2022-01-31 07:16:55 +03:00
|
|
|
def __init__(self, provides: Optional[Union[_Callable[..., T], str]] = None, *args: Injection, **kwargs: Injection) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
@property
|
2021-08-24 04:24:36 +03:00
|
|
|
def cls(self) -> Type[T]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
@property
|
2021-08-24 04:24:36 +03:00
|
|
|
def provides(self) -> Optional[_Callable[..., T]]: ...
|
2022-01-31 07:16:55 +03:00
|
|
|
def set_provides(self, provides: Optional[Union[_Callable[..., T], str]]) -> Factory[T]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
@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
|
2021-01-11 03:26:15 +03:00
|
|
|
def kwargs(self) -> _Dict[Any, Injection]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
def add_kwargs(self, **kwargs: Injection) -> Factory[T]: ...
|
|
|
|
def set_kwargs(self, **kwargs: Injection) -> Factory[T]: ...
|
|
|
|
def clear_kwargs(self) -> Factory[T]: ...
|
|
|
|
@property
|
2021-01-11 03:26:15 +03:00
|
|
|
def attributes(self) -> _Dict[Any, Injection]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
def add_attributes(self, **kwargs: Injection) -> Factory[T]: ...
|
|
|
|
def set_attributes(self, **kwargs: Injection) -> Factory[T]: ...
|
|
|
|
def clear_attributes(self) -> Factory[T]: ...
|
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class DelegatedFactory(Factory[T]): ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class AbstractFactory(Factory[T]):
|
2021-03-03 16:28:10 +03:00
|
|
|
def override(self, provider: Factory) -> OverridingContext[P]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
class FactoryDelegate(Delegate):
|
|
|
|
def __init__(self, factory: Factory): ...
|
|
|
|
|
|
|
|
|
2022-01-10 05:45:20 +03:00
|
|
|
class FactoryAggregate(Aggregate[T]):
|
2021-11-29 01:13:17 +03:00
|
|
|
def __getattr__(self, provider_name: Any) -> Factory[T]: ...
|
2021-11-26 19:50:19 +03:00
|
|
|
@property
|
2021-11-29 01:13:17 +03:00
|
|
|
def factories(self) -> _Dict[Any, Factory[T]]: ...
|
|
|
|
def set_factories(self, provider_dict: Optional[_Dict[Any, Factory[T]]] = None, **provider_kwargs: Factory[T]) -> FactoryAggregate[T]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class BaseSingleton(Provider[T]):
|
2020-08-27 05:24:20 +03:00
|
|
|
provided_type = Optional[Type]
|
2022-01-31 07:16:55 +03:00
|
|
|
def __init__(self, provides: Optional[Union[_Callable[..., T], str]] = None, *args: Injection, **kwargs: Injection) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
@property
|
2021-08-24 04:24:36 +03:00
|
|
|
def cls(self) -> Type[T]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
@property
|
2021-08-24 04:24:36 +03:00
|
|
|
def provides(self) -> Optional[_Callable[..., T]]: ...
|
2022-01-31 07:16:55 +03:00
|
|
|
def set_provides(self, provides: Optional[Union[_Callable[..., T], str]]) -> BaseSingleton[T]: ...
|
2021-02-01 17:42:21 +03:00
|
|
|
@property
|
2020-08-27 05:24:20 +03:00
|
|
|
def args(self) -> Tuple[Injection]: ...
|
2021-01-11 03:26:15 +03:00
|
|
|
def add_args(self, *args: Injection) -> BaseSingleton[T]: ...
|
|
|
|
def set_args(self, *args: Injection) -> BaseSingleton[T]: ...
|
|
|
|
def clear_args(self) -> BaseSingleton[T]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
@property
|
2021-01-11 03:26:15 +03:00
|
|
|
def kwargs(self) -> _Dict[Any, Injection]: ...
|
|
|
|
def add_kwargs(self, **kwargs: Injection) -> BaseSingleton[T]: ...
|
|
|
|
def set_kwargs(self, **kwargs: Injection) -> BaseSingleton[T]: ...
|
|
|
|
def clear_kwargs(self) -> BaseSingleton[T]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
@property
|
2021-01-11 03:26:15 +03:00
|
|
|
def attributes(self) -> _Dict[Any, Injection]: ...
|
|
|
|
def add_attributes(self, **kwargs: Injection) -> BaseSingleton[T]: ...
|
|
|
|
def set_attributes(self, **kwargs: Injection) -> BaseSingleton[T]: ...
|
|
|
|
def clear_attributes(self) -> BaseSingleton[T]: ...
|
2021-03-03 16:28:10 +03:00
|
|
|
def reset(self) -> SingletonResetContext[BS]: ...
|
|
|
|
def full_reset(self) -> SingletonFullResetContext[BS]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class Singleton(BaseSingleton[T]): ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class DelegatedSingleton(Singleton[T]): ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class ThreadSafeSingleton(Singleton[T]): ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class DelegatedThreadSafeSingleton(ThreadSafeSingleton[T]): ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class ThreadLocalSingleton(BaseSingleton[T]): ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-04-19 04:37:55 +03:00
|
|
|
class ContextLocalSingleton(BaseSingleton[T]): ...
|
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class DelegatedThreadLocalSingleton(ThreadLocalSingleton[T]): ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class AbstractSingleton(BaseSingleton[T]):
|
2021-03-03 16:28:10 +03:00
|
|
|
def override(self, provider: BaseSingleton) -> OverridingContext[P]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
class SingletonDelegate(Delegate):
|
2022-01-31 07:16:55 +03:00
|
|
|
def __init__(self, singleton: BaseSingleton): ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class List(Provider[_List]):
|
2020-08-27 05:24:20 +03:00
|
|
|
def __init__(self, *args: Injection): ...
|
|
|
|
@property
|
|
|
|
def args(self) -> Tuple[Injection]: ...
|
2021-01-11 03:26:15 +03:00
|
|
|
def add_args(self, *args: Injection) -> List[T]: ...
|
|
|
|
def set_args(self, *args: Injection) -> List[T]: ...
|
|
|
|
def clear_args(self) -> List[T]: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class Dict(Provider[_Dict]):
|
2020-11-21 01:30:42 +03:00
|
|
|
def __init__(self, dict_: Optional[_Dict[Any, Injection]] = None, **kwargs: Injection): ...
|
2020-10-22 21:49:39 +03:00
|
|
|
@property
|
|
|
|
def kwargs(self) -> _Dict[Any, Injection]: ...
|
2020-11-21 01:30:42 +03:00
|
|
|
def add_kwargs(self, dict_: Optional[_Dict[Any, Injection]] = None, **kwargs: Injection) -> Dict: ...
|
|
|
|
def set_kwargs(self, dict_: Optional[_Dict[Any, Injection]] = None, **kwargs: Injection) -> Dict: ...
|
2020-10-22 21:49:39 +03:00
|
|
|
def clear_kwargs(self) -> Dict: ...
|
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class Resource(Provider[T]):
|
2020-10-25 03:56:32 +03:00
|
|
|
@overload
|
2021-03-20 20:16:51 +03:00
|
|
|
def __init__(self, provides: Optional[Type[resources.Resource[T]]] = None, *args: Injection, **kwargs: Injection) -> None: ...
|
2021-01-11 03:26:15 +03:00
|
|
|
@overload
|
2021-03-20 20:16:51 +03:00
|
|
|
def __init__(self, provides: Optional[Type[resources.AsyncResource[T]]] = None, *args: Injection, **kwargs: Injection) -> None: ...
|
2020-10-25 03:56:32 +03:00
|
|
|
@overload
|
2021-03-20 20:16:51 +03:00
|
|
|
def __init__(self, provides: Optional[_Callable[..., _Iterator[T]]] = None, *args: Injection, **kwargs: Injection) -> None: ...
|
2020-10-25 03:56:32 +03:00
|
|
|
@overload
|
2021-03-20 20:16:51 +03:00
|
|
|
def __init__(self, provides: Optional[_Callable[..., _AsyncIterator[T]]] = None, *args: Injection, **kwargs: Injection) -> None: ...
|
2021-01-11 03:26:15 +03:00
|
|
|
@overload
|
2021-03-20 20:16:51 +03:00
|
|
|
def __init__(self, provides: Optional[_Callable[..., _Coroutine[Injection, Injection, T]]] = None, *args: Injection, **kwargs: Injection) -> None: ...
|
2021-01-11 03:26:15 +03:00
|
|
|
@overload
|
2022-01-31 07:16:55 +03:00
|
|
|
def __init__(self, provides: Optional[Union[_Callable[..., T], str]] = None, *args: Injection, **kwargs: Injection) -> None: ...
|
2020-10-25 03:56:32 +03:00
|
|
|
@property
|
2021-03-20 20:16:51 +03:00
|
|
|
def provides(self) -> Optional[_Callable[..., Any]]: ...
|
|
|
|
def set_provides(self, provides: Optional[Any]) -> Resource[T]: ...
|
2021-02-01 17:42:21 +03:00
|
|
|
@property
|
2020-10-25 03:56:32 +03:00
|
|
|
def args(self) -> Tuple[Injection]: ...
|
2021-01-11 03:26:15 +03:00
|
|
|
def add_args(self, *args: Injection) -> Resource[T]: ...
|
|
|
|
def set_args(self, *args: Injection) -> Resource[T]: ...
|
|
|
|
def clear_args(self) -> Resource[T]: ...
|
2020-10-25 03:56:32 +03:00
|
|
|
@property
|
|
|
|
def kwargs(self) -> _Dict[Any, Injection]: ...
|
2021-01-11 03:26:15 +03:00
|
|
|
def add_kwargs(self, **kwargs: Injection) -> Resource[T]: ...
|
|
|
|
def set_kwargs(self, **kwargs: Injection) -> Resource[T]: ...
|
|
|
|
def clear_kwargs(self) -> Resource[T]: ...
|
2020-10-25 03:56:32 +03:00
|
|
|
@property
|
|
|
|
def initialized(self) -> bool: ...
|
2021-01-11 03:26:15 +03:00
|
|
|
def init(self) -> Optional[Awaitable[T]]: ...
|
|
|
|
def shutdown(self) -> Optional[Awaitable]: ...
|
2020-10-25 03:56:32 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class Container(Provider[T]):
|
2021-02-07 22:13:23 +03:00
|
|
|
def __init__(self, container_cls: Type[T], container: Optional[T] = None, **overriding_providers: Union[Provider, Any]) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
def __getattr__(self, name: str) -> Provider: ...
|
2020-10-09 22:16:27 +03:00
|
|
|
@property
|
|
|
|
def container(self) -> T: ...
|
2021-02-13 17:16:38 +03:00
|
|
|
def resolve_provider_name(self, provider: Provider) -> str: ...
|
|
|
|
@property
|
|
|
|
def parent(self) -> Optional[ProviderParent]: ...
|
|
|
|
@property
|
|
|
|
def parent_name(self) -> Optional[str]: ...
|
|
|
|
def assign_parent(self, parent: ProviderParent) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-01-11 03:26:15 +03:00
|
|
|
class Selector(Provider[Any]):
|
2021-03-20 20:16:51 +03:00
|
|
|
def __init__(self, selector: Optional[_Callable[..., Any]] = None, **providers: Provider): ...
|
2020-08-27 05:24:20 +03:00
|
|
|
def __getattr__(self, name: str) -> Provider: ...
|
2021-03-20 20:16:51 +03:00
|
|
|
|
|
|
|
@property
|
|
|
|
def selector(self) -> Optional[_Callable[..., Any]]: ...
|
|
|
|
def set_selector(self, selector: Optional[_Callable[..., Any]]) -> Selector: ...
|
|
|
|
|
2020-08-27 05:24:20 +03:00
|
|
|
@property
|
2020-10-22 21:49:39 +03:00
|
|
|
def providers(self) -> _Dict[str, Provider]: ...
|
2021-03-20 20:16:51 +03:00
|
|
|
def set_providers(self, **providers: Provider) -> Selector: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
class ProvidedInstanceFluentInterface:
|
2020-09-04 00:48:45 +03:00
|
|
|
def __getattr__(self, item: Any) -> AttributeGetter: ...
|
|
|
|
def __getitem__(self, item: Any) -> ItemGetter: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
def call(self, *args: Injection, **kwargs: Injection) -> MethodCaller: ...
|
2021-03-20 20:16:51 +03:00
|
|
|
@property
|
|
|
|
def provides(self) -> Optional[Provider]: ...
|
|
|
|
def set_provides(self, provides: Optional[Provider]) -> ProvidedInstanceFluentInterface: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
class ProvidedInstance(Provider, ProvidedInstanceFluentInterface):
|
2021-03-20 20:16:51 +03:00
|
|
|
def __init__(self, provides: Optional[Provider] = None) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
class AttributeGetter(Provider, ProvidedInstanceFluentInterface):
|
2021-03-20 20:16:51 +03:00
|
|
|
def __init__(self, provides: Optional[Provider] = None, name: Optional[str] = None) -> None: ...
|
|
|
|
@property
|
|
|
|
def name(self) -> Optional[str]: ...
|
|
|
|
def set_name(self, name: Optional[str]) -> ProvidedInstanceFluentInterface: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
class ItemGetter(Provider, ProvidedInstanceFluentInterface):
|
2021-03-20 20:16:51 +03:00
|
|
|
def __init__(self, provides: Optional[Provider] = None, name: Optional[str] = None) -> None: ...
|
|
|
|
@property
|
|
|
|
def name(self) -> Optional[str]: ...
|
|
|
|
def set_name(self, name: Optional[str]) -> ProvidedInstanceFluentInterface: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
class MethodCaller(Provider, ProvidedInstanceFluentInterface):
|
2021-03-20 20:16:51 +03:00
|
|
|
def __init__(self, provides: Optional[Provider] = None, *args: Injection, **kwargs: Injection) -> None: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2021-03-03 16:28:10 +03:00
|
|
|
class OverridingContext(Generic[T]):
|
|
|
|
def __init__(self, overridden: Provider, overriding: Provider): ...
|
|
|
|
def __enter__(self) -> T: ...
|
2022-01-10 05:45:20 +03:00
|
|
|
def __exit__(self, *_: Any) -> None:
|
|
|
|
pass
|
|
|
|
...
|
2021-03-03 16:28:10 +03:00
|
|
|
|
|
|
|
|
|
|
|
class BaseSingletonResetContext(Generic[T]):
|
|
|
|
def __init__(self, provider: T): ...
|
|
|
|
def __enter__(self) -> T: ...
|
|
|
|
def __exit__(self, *_: Any) -> None: ...
|
|
|
|
|
|
|
|
|
|
|
|
class SingletonResetContext(BaseSingletonResetContext):
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
|
|
class SingletonFullResetContext(BaseSingletonResetContext):
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
|
|
CHILD_PROVIDERS: Tuple[Provider]
|
|
|
|
|
|
|
|
|
2020-08-27 05:24:20 +03:00
|
|
|
def is_provider(instance: Any) -> bool: ...
|
|
|
|
|
|
|
|
|
|
|
|
def ensure_is_provider(instance: Any) -> Provider: ...
|
|
|
|
|
|
|
|
|
|
|
|
def is_delegated(instance: Any) -> bool: ...
|
|
|
|
|
|
|
|
|
|
|
|
def represent_provider(provider: Provider, provides: Any) -> str: ...
|
|
|
|
|
|
|
|
|
2020-10-22 21:49:39 +03:00
|
|
|
def deepcopy(instance: Any, memo: Optional[_Dict[Any, Any]] = None): Any: ...
|
2020-08-27 05:24:20 +03:00
|
|
|
|
|
|
|
|
2020-10-22 21:49:39 +03:00
|
|
|
def merge_dicts(dict1: _Dict[Any, Any], dict2: _Dict[Any, Any]) -> _Dict[Any, Any]: ...
|
2021-01-22 02:00:24 +03:00
|
|
|
|
|
|
|
|
2021-02-01 17:42:21 +03:00
|
|
|
def traverse(*providers: Provider, types: Optional[_Iterable[Type]]=None) -> _Iterator[Provider]: ...
|
|
|
|
|
|
|
|
|
2021-01-22 02:00:24 +03:00
|
|
|
if yaml:
|
|
|
|
class YamlLoader(yaml.SafeLoader): ...
|
|
|
|
else:
|
|
|
|
class YamlLoader: ...
|
2021-02-03 17:21:32 +03:00
|
|
|
|
|
|
|
if pydantic:
|
|
|
|
PydanticSettings = pydantic.BaseSettings
|
|
|
|
else:
|
|
|
|
PydanticSettings = Any
|