|
| 1 | +from _typeshed import Incomplete |
| 2 | +from typing import Any, Awaitable, Callable, Hashable, Optional, Type, TypeVar, Union, overload |
| 3 | + |
| 4 | +logger: Incomplete |
| 5 | +Injectable = Union[object, Any] |
| 6 | +T = TypeVar('T', bound=Injectable) |
| 7 | +Binding = Union[Type[Injectable], Hashable] |
| 8 | +Constructor = Callable[[], Injectable] |
| 9 | +Provider = Constructor |
| 10 | +BinderCallable: Incomplete |
| 11 | + |
| 12 | +class ConstructorTypeError(TypeError): |
| 13 | + def __init__(self, constructor: Callable, previous_error: TypeError) -> None: ... |
| 14 | + |
| 15 | +class Binder: |
| 16 | + def __init__(self) -> None: ... |
| 17 | + def install(self, config: BinderCallable) -> Binder: ... |
| 18 | + def bind(self, cls: Binding, instance: T) -> Binder: ... |
| 19 | + def bind_to_constructor(self, cls: Binding, constructor: Constructor) -> Binder: ... |
| 20 | + def bind_to_provider(self, cls: Binding, provider: Provider) -> Binder: ... |
| 21 | + |
| 22 | +class Injector: |
| 23 | + def __init__(self, config: Optional[BinderCallable] = ..., bind_in_runtime: bool = ...) -> None: ... |
| 24 | + @overload |
| 25 | + def get_instance(self, cls: Type[T]) -> T: ... |
| 26 | + @overload |
| 27 | + def get_instance(self, cls: Hashable) -> Injectable: ... |
| 28 | + |
| 29 | +class InjectorException(Exception): ... |
| 30 | + |
| 31 | +class _ConstructorBinding: |
| 32 | + def __init__(self, constructor: Callable[[], T]) -> None: ... |
| 33 | + def __call__(self) -> T: ... |
| 34 | + |
| 35 | +class _AttributeInjection: |
| 36 | + def __init__(self, cls: Binding) -> None: ... |
| 37 | + def __get__(self, obj: Any, owner: Any) -> Injectable: ... |
| 38 | + |
| 39 | +class _AttributeInjectionDataclass: |
| 40 | + def __init__(self, cls: Binding) -> None: ... |
| 41 | + def __get__(self, instance, owner) -> T: ... |
| 42 | + |
| 43 | +class _ParameterInjection: |
| 44 | + def __init__(self, name: str, cls: Optional[Binding] = ...) -> None: ... |
| 45 | + def __call__(self, func: Callable[..., Union[T, Awaitable[T]]]) -> Callable[..., Union[T, Awaitable[T]]]: ... |
| 46 | + |
| 47 | +class _ParametersInjection: |
| 48 | + def __init__(self, **kwargs: Any) -> None: ... |
| 49 | + def __call__(self, func: Callable[..., Union[Awaitable[T], T]]) -> Callable[..., Union[Awaitable[T], T]]: ... |
| 50 | + |
| 51 | +def configure(config: Optional[BinderCallable] = ..., bind_in_runtime: bool = ...) -> Injector: ... |
| 52 | +def configure_once(config: Optional[BinderCallable] = ..., bind_in_runtime: bool = ...) -> Injector: ... |
| 53 | +def clear_and_configure(config: Optional[BinderCallable] = ..., bind_in_runtime: bool = ...) -> Injector: ... |
| 54 | +def is_configured() -> bool: ... |
| 55 | +def clear() -> None: ... |
| 56 | +@overload |
| 57 | +def instance(cls) -> T: ... |
| 58 | +@overload |
| 59 | +def instance(cls) -> Injectable: ... |
| 60 | +@overload |
| 61 | +def attr(cls) -> T: ... |
| 62 | +@overload |
| 63 | +def attr(cls) -> Injectable: ... |
| 64 | +@overload |
| 65 | +def attr_dc(cls) -> T: ... |
| 66 | +@overload |
| 67 | +def attr_dc(cls) -> Injectable: ... |
| 68 | +def param(name: str, cls: Optional[Binding] = ...) -> Callable: ... |
| 69 | +def params(**args_to_classes: Binding) -> Callable: ... |
| 70 | +def autoparams(*selected: str) -> Callable: ... |
| 71 | +def get_injector() -> Optional[Injector]: ... |
| 72 | +def get_injector_or_die() -> Injector: ... |
0 commit comments