Add .initializer attribute to Resource provider

This commit is contained in:
Roman Mogylatov 2021-02-01 08:55:27 -05:00
parent 7a2c61e9f8
commit 385437e2d4
4 changed files with 1910 additions and 1843 deletions

View File

@ -12,6 +12,7 @@ Development version
- Add ``.provides`` attribute to ``Singleton`` and its subclasses.
It's a consistency change to make ``Singleton`` match ``Callable``
and ``Factory`` interfaces.
- Add ``.initializer`` attribute to ``Resource`` provider.
- Update string representation of ``Resource`` provider.
4.13.2

File diff suppressed because it is too large Load Diff

View File

@ -319,6 +319,8 @@ class Resource(Provider[T]):
@overload
def __init__(self, initializer: _Callable[..., T], *args: Injection, **kwargs: Injection) -> None: ...
@property
def initializer(self) -> _Callable[..., Any]: ...
@property
def args(self) -> Tuple[Injection]: ...
def add_args(self, *args: Injection) -> Resource[T]: ...
def set_args(self, *args: Injection) -> Resource[T]: ...

View File

@ -2999,6 +2999,11 @@ cdef class Resource(Provider):
"""
return represent_provider(provider=self, provides=self.__initializer)
@property
def initializer(self):
"""Return initializer."""
return self.__initializer
@property
def args(self):
"""Return positional argument injections."""