mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-26 11:33:58 +03:00
Update doc blocks with *args and **kwargs
This commit is contained in:
parent
9a785de4b5
commit
ea0f9d8306
|
@ -13,6 +13,8 @@ Development version
|
||||||
- Add ``DelegatedCoroutine`` provider.
|
- Add ``DelegatedCoroutine`` provider.
|
||||||
- Add ``AbstractCoroutine`` provider.
|
- Add ``AbstractCoroutine`` provider.
|
||||||
- Add ``CoroutineDelegate`` provider.
|
- Add ``CoroutineDelegate`` provider.
|
||||||
|
- Fix type-hinting of ``*args`` & ``**kwargs`` that was specified in doc
|
||||||
|
blocks of various providers and caused inspection problems in PyCharm.
|
||||||
- Regenerate C sources using Cython 0.28.5.
|
- Regenerate C sources using Cython 0.28.5.
|
||||||
|
|
||||||
3.13.2
|
3.13.2
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -352,12 +352,6 @@ cdef class Dependency(Provider):
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
"""Return provided instance.
|
"""Return provided instance.
|
||||||
|
|
||||||
:param args: Tuple of context positional arguments.
|
|
||||||
:type args: tuple[object]
|
|
||||||
|
|
||||||
:param kwargs: Dictionary of context keyword arguments.
|
|
||||||
:type kwargs: dict[str, object]
|
|
||||||
|
|
||||||
:raise: :py:exc:`dependency_injector.errors.Error`
|
:raise: :py:exc:`dependency_injector.errors.Error`
|
||||||
|
|
||||||
:rtype: object
|
:rtype: object
|
||||||
|
@ -634,12 +628,6 @@ cdef class Callable(Provider):
|
||||||
|
|
||||||
:param provides: Wrapped callable.
|
:param provides: Wrapped callable.
|
||||||
:type provides: callable
|
:type provides: callable
|
||||||
|
|
||||||
:param args: Tuple of positional argument injections.
|
|
||||||
:type args: tuple[object]
|
|
||||||
|
|
||||||
:param kwargs: Dictionary of context keyword argument injections.
|
|
||||||
:type kwargs: dict[str, object]
|
|
||||||
"""
|
"""
|
||||||
if not callable(provides):
|
if not callable(provides):
|
||||||
raise Error('Provider {0} expected to get callable, '
|
raise Error('Provider {0} expected to get callable, '
|
||||||
|
@ -702,10 +690,7 @@ cdef class Callable(Provider):
|
||||||
return tuple(args)
|
return tuple(args)
|
||||||
|
|
||||||
def add_args(self, *args):
|
def add_args(self, *args):
|
||||||
"""Add postional argument injections.
|
"""Add positional argument injections.
|
||||||
|
|
||||||
:param args: Tuple of injections.
|
|
||||||
:type args: tuple
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
|
@ -718,9 +703,6 @@ cdef class Callable(Provider):
|
||||||
|
|
||||||
Existing positional argument injections are dropped.
|
Existing positional argument injections are dropped.
|
||||||
|
|
||||||
:param args: Tuple of injections.
|
|
||||||
:type args: tuple
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
self.__args = parse_positional_injections(args)
|
self.__args = parse_positional_injections(args)
|
||||||
|
@ -752,9 +734,6 @@ cdef class Callable(Provider):
|
||||||
def add_kwargs(self, **kwargs):
|
def add_kwargs(self, **kwargs):
|
||||||
"""Add keyword argument injections.
|
"""Add keyword argument injections.
|
||||||
|
|
||||||
:param kwargs: Dictionary of injections.
|
|
||||||
:type kwargs: dict
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
self.__kwargs += parse_named_injections(kwargs)
|
self.__kwargs += parse_named_injections(kwargs)
|
||||||
|
@ -766,9 +745,6 @@ cdef class Callable(Provider):
|
||||||
|
|
||||||
Existing keyword argument injections are dropped.
|
Existing keyword argument injections are dropped.
|
||||||
|
|
||||||
:param kwargs: Dictionary of injections.
|
|
||||||
:type kwargs: dict
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
self.__kwargs = parse_named_injections(kwargs)
|
self.__kwargs = parse_named_injections(kwargs)
|
||||||
|
@ -892,15 +868,9 @@ cdef class Coroutine(Callable):
|
||||||
|
|
||||||
:param provides: Wrapped callable.
|
:param provides: Wrapped callable.
|
||||||
:type provides: callable
|
:type provides: callable
|
||||||
|
|
||||||
:param args: Tuple of positional argument injections.
|
|
||||||
:type args: tuple[object]
|
|
||||||
|
|
||||||
:param kwargs: Dictionary of context keyword argument injections.
|
|
||||||
:type kwargs: dict[str, object]
|
|
||||||
"""
|
"""
|
||||||
if not asyncio:
|
if not asyncio:
|
||||||
raise Error('Module asyncio is not available')
|
raise Error('Package asyncio is not available')
|
||||||
|
|
||||||
if not asyncio.iscoroutinefunction(provides):
|
if not asyncio.iscoroutinefunction(provides):
|
||||||
raise Error('Provider {0} expected to get coroutine function, '
|
raise Error('Provider {0} expected to get coroutine function, '
|
||||||
|
@ -1211,12 +1181,6 @@ cdef class Factory(Provider):
|
||||||
|
|
||||||
:param provides: Provided type.
|
:param provides: Provided type.
|
||||||
:type provides: type
|
:type provides: type
|
||||||
|
|
||||||
:param args: Tuple of positional argument injections.
|
|
||||||
:type args: tuple[object]
|
|
||||||
|
|
||||||
:param kwargs: Dictionary of context keyword argument injections.
|
|
||||||
:type kwargs: dict[str, object]
|
|
||||||
"""
|
"""
|
||||||
if (self.__class__.provided_type and
|
if (self.__class__.provided_type and
|
||||||
not issubclass(provides, self.__class__.provided_type)):
|
not issubclass(provides, self.__class__.provided_type)):
|
||||||
|
@ -1270,9 +1234,6 @@ cdef class Factory(Provider):
|
||||||
def add_args(self, *args):
|
def add_args(self, *args):
|
||||||
"""Add __init__ postional argument injections.
|
"""Add __init__ postional argument injections.
|
||||||
|
|
||||||
:param args: Tuple of injections.
|
|
||||||
:type args: tuple
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
self.__instantiator.add_args(*args)
|
self.__instantiator.add_args(*args)
|
||||||
|
@ -1283,9 +1244,6 @@ cdef class Factory(Provider):
|
||||||
|
|
||||||
Existing __init__ positional argument injections are dropped.
|
Existing __init__ positional argument injections are dropped.
|
||||||
|
|
||||||
:param args: Tuple of injections.
|
|
||||||
:type args: tuple
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
self.__instantiator.set_args(*args)
|
self.__instantiator.set_args(*args)
|
||||||
|
@ -1307,9 +1265,6 @@ cdef class Factory(Provider):
|
||||||
def add_kwargs(self, **kwargs):
|
def add_kwargs(self, **kwargs):
|
||||||
"""Add __init__ keyword argument injections.
|
"""Add __init__ keyword argument injections.
|
||||||
|
|
||||||
:param kwargs: Dictionary of injections.
|
|
||||||
:type kwargs: dict
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
self.__instantiator.add_kwargs(**kwargs)
|
self.__instantiator.add_kwargs(**kwargs)
|
||||||
|
@ -1320,9 +1275,6 @@ cdef class Factory(Provider):
|
||||||
|
|
||||||
Existing __init__ keyword argument injections are dropped.
|
Existing __init__ keyword argument injections are dropped.
|
||||||
|
|
||||||
:param kwargs: Dictionary of injections.
|
|
||||||
:type kwargs: dict
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
self.__instantiator.set_kwargs(**kwargs)
|
self.__instantiator.set_kwargs(**kwargs)
|
||||||
|
@ -1352,9 +1304,6 @@ cdef class Factory(Provider):
|
||||||
def add_attributes(self, **kwargs):
|
def add_attributes(self, **kwargs):
|
||||||
"""Add attribute injections.
|
"""Add attribute injections.
|
||||||
|
|
||||||
:param args: Tuple of injections.
|
|
||||||
:type args: tuple
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
self.__attributes += parse_named_injections(kwargs)
|
self.__attributes += parse_named_injections(kwargs)
|
||||||
|
@ -1366,9 +1315,6 @@ cdef class Factory(Provider):
|
||||||
|
|
||||||
Existing attribute injections are dropped.
|
Existing attribute injections are dropped.
|
||||||
|
|
||||||
:param args: Tuple of injections.
|
|
||||||
:type args: tuple
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
self.__attributes = parse_named_injections(kwargs)
|
self.__attributes = parse_named_injections(kwargs)
|
||||||
|
@ -1529,9 +1475,6 @@ cdef class FactoryAggregate(Provider):
|
||||||
def override(self, _):
|
def override(self, _):
|
||||||
"""Override provider with another provider.
|
"""Override provider with another provider.
|
||||||
|
|
||||||
:param provider: Overriding provider.
|
|
||||||
:type provider: :py:class:`Provider`
|
|
||||||
|
|
||||||
:raise: :py:exc:`dependency_injector.errors.Error`
|
:raise: :py:exc:`dependency_injector.errors.Error`
|
||||||
|
|
||||||
:return: Overriding context.
|
:return: Overriding context.
|
||||||
|
@ -1558,12 +1501,6 @@ cdef class BaseSingleton(Provider):
|
||||||
|
|
||||||
:param provides: Provided type.
|
:param provides: Provided type.
|
||||||
:type provides: type
|
:type provides: type
|
||||||
|
|
||||||
:param args: Tuple of positional argument injections.
|
|
||||||
:type args: tuple[object]
|
|
||||||
|
|
||||||
:param kwargs: Dictionary of context keyword argument injections.
|
|
||||||
:type kwargs: dict[str, object]
|
|
||||||
"""
|
"""
|
||||||
if (self.__class__.provided_type and
|
if (self.__class__.provided_type and
|
||||||
not issubclass(provides, self.__class__.provided_type)):
|
not issubclass(provides, self.__class__.provided_type)):
|
||||||
|
@ -1612,10 +1549,7 @@ cdef class BaseSingleton(Provider):
|
||||||
return self.__instantiator.args
|
return self.__instantiator.args
|
||||||
|
|
||||||
def add_args(self, *args):
|
def add_args(self, *args):
|
||||||
"""Add __init__ postional argument injections.
|
"""Add __init__ positional argument injections.
|
||||||
|
|
||||||
:param args: Tuple of injections.
|
|
||||||
:type args: tuple
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
|
@ -1623,20 +1557,17 @@ cdef class BaseSingleton(Provider):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def set_args(self, *args):
|
def set_args(self, *args):
|
||||||
"""Set __init__ postional argument injections.
|
"""Set __init__ positional argument injections.
|
||||||
|
|
||||||
Existing __init__ positional argument injections are dropped.
|
Existing __init__ positional argument injections are dropped.
|
||||||
|
|
||||||
:param args: Tuple of injections.
|
|
||||||
:type args: tuple
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
self.__instantiator.set_args(*args)
|
self.__instantiator.set_args(*args)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def clear_args(self):
|
def clear_args(self):
|
||||||
"""Drop __init__ postional argument injections.
|
"""Drop __init__ positional argument injections.
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
|
@ -1651,9 +1582,6 @@ cdef class BaseSingleton(Provider):
|
||||||
def add_kwargs(self, **kwargs):
|
def add_kwargs(self, **kwargs):
|
||||||
"""Add __init__ keyword argument injections.
|
"""Add __init__ keyword argument injections.
|
||||||
|
|
||||||
:param kwargs: Dictionary of injections.
|
|
||||||
:type kwargs: dict
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
self.__instantiator.add_kwargs(**kwargs)
|
self.__instantiator.add_kwargs(**kwargs)
|
||||||
|
@ -1664,9 +1592,6 @@ cdef class BaseSingleton(Provider):
|
||||||
|
|
||||||
Existing __init__ keyword argument injections are dropped.
|
Existing __init__ keyword argument injections are dropped.
|
||||||
|
|
||||||
:param kwargs: Dictionary of injections.
|
|
||||||
:type kwargs: dict
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
self.__instantiator.set_kwargs(**kwargs)
|
self.__instantiator.set_kwargs(**kwargs)
|
||||||
|
@ -1688,9 +1613,6 @@ cdef class BaseSingleton(Provider):
|
||||||
def add_attributes(self, **kwargs):
|
def add_attributes(self, **kwargs):
|
||||||
"""Add attribute injections.
|
"""Add attribute injections.
|
||||||
|
|
||||||
:param args: Tuple of injections.
|
|
||||||
:type args: tuple
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
self.__instantiator.add_attributes(**kwargs)
|
self.__instantiator.add_attributes(**kwargs)
|
||||||
|
@ -1701,9 +1623,6 @@ cdef class BaseSingleton(Provider):
|
||||||
|
|
||||||
Existing attribute injections are dropped.
|
Existing attribute injections are dropped.
|
||||||
|
|
||||||
:param args: Tuple of injections.
|
|
||||||
:type args: tuple
|
|
||||||
|
|
||||||
:return: Reference ``self``
|
:return: Reference ``self``
|
||||||
"""
|
"""
|
||||||
self.__instantiator.set_attributes(**kwargs)
|
self.__instantiator.set_attributes(**kwargs)
|
||||||
|
@ -1761,12 +1680,6 @@ cdef class Singleton(BaseSingleton):
|
||||||
|
|
||||||
:param provides: Provided type.
|
:param provides: Provided type.
|
||||||
:type provides: type
|
:type provides: type
|
||||||
|
|
||||||
:param args: Tuple of positional argument injections.
|
|
||||||
:type args: tuple[object]
|
|
||||||
|
|
||||||
:param kwargs: Dictionary of context keyword argument injections.
|
|
||||||
:type kwargs: dict[str, object]
|
|
||||||
"""
|
"""
|
||||||
self.__storage = None
|
self.__storage = None
|
||||||
super(Singleton, self).__init__(provides, *args, **kwargs)
|
super(Singleton, self).__init__(provides, *args, **kwargs)
|
||||||
|
@ -1821,12 +1734,6 @@ cdef class ThreadSafeSingleton(BaseSingleton):
|
||||||
|
|
||||||
:param provides: Provided type.
|
:param provides: Provided type.
|
||||||
:type provides: type
|
:type provides: type
|
||||||
|
|
||||||
:param args: Tuple of positional argument injections.
|
|
||||||
:type args: tuple[object]
|
|
||||||
|
|
||||||
:param kwargs: Dictionary of context keyword argument injections.
|
|
||||||
:type kwargs: dict[str, object]
|
|
||||||
"""
|
"""
|
||||||
self.__storage = None
|
self.__storage = None
|
||||||
self.__storage_lock = self.__class__.storage_lock
|
self.__storage_lock = self.__class__.storage_lock
|
||||||
|
@ -1892,12 +1799,6 @@ cdef class ThreadLocalSingleton(BaseSingleton):
|
||||||
|
|
||||||
:param provides: Provided type.
|
:param provides: Provided type.
|
||||||
:type provides: type
|
:type provides: type
|
||||||
|
|
||||||
:param args: Tuple of positional argument injections.
|
|
||||||
:type args: tuple[object]
|
|
||||||
|
|
||||||
:param kwargs: Dictionary of context keyword argument injections.
|
|
||||||
:type kwargs: dict[str, object]
|
|
||||||
"""
|
"""
|
||||||
self.__storage = threading.local()
|
self.__storage = threading.local()
|
||||||
super(ThreadLocalSingleton, self).__init__(provides, *args, **kwargs)
|
super(ThreadLocalSingleton, self).__init__(provides, *args, **kwargs)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user