mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 09:36:48 +03:00
Fix recursive copying issue in `Delegate
` provider
This commit is contained in:
parent
c14ff96773
commit
22629544a4
|
@ -9,6 +9,9 @@ follows `Semantic versioning`_
|
||||||
|
|
||||||
Development version
|
Development version
|
||||||
-------------------
|
-------------------
|
||||||
|
- Fix recursive copying issue in ``Delegate`` provider.
|
||||||
|
See issue: `#245 <https://github.com/ets-labs/python-dependency-injector/issues/245>`_.
|
||||||
|
Thanks to `@GitterRemote <https://github.com/GitterRemote>`_ for reporting the issue.
|
||||||
- Add docs and example for ``Factory.add_attributes()`` method.
|
- Add docs and example for ``Factory.add_attributes()`` method.
|
||||||
- Remove legacy css file.
|
- Remove legacy css file.
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -91,9 +91,10 @@ class Self(Provider[T]):
|
||||||
|
|
||||||
|
|
||||||
class Delegate(Provider[Provider]):
|
class Delegate(Provider[Provider]):
|
||||||
def __init__(self, provides: Provider) -> None: ...
|
def __init__(self, provides: Optional[Provider] = None) -> None: ...
|
||||||
@property
|
@property
|
||||||
def provides(self) -> Provider: ...
|
def provides(self) -> Optional[Provider]: ...
|
||||||
|
def set_provides(self, provides: Optional[Provider]): ...
|
||||||
|
|
||||||
|
|
||||||
class Dependency(Provider[T]):
|
class Dependency(Provider[T]):
|
||||||
|
|
|
@ -519,13 +519,14 @@ cdef class Delegate(Provider):
|
||||||
:type: object
|
:type: object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, provides):
|
def __init__(self, provides=None):
|
||||||
"""Initializer.
|
"""Initializer.
|
||||||
|
|
||||||
:param provides: Value that have to be provided.
|
:param provides: Value that have to be provided.
|
||||||
:type provides: :py:class:`Provider`
|
:type provides: :py:class:`Provider`
|
||||||
"""
|
"""
|
||||||
self.__provides = ensure_is_provider(provides)
|
self.__provides = None
|
||||||
|
self.set_provides(provides)
|
||||||
super(Delegate, self).__init__()
|
super(Delegate, self).__init__()
|
||||||
|
|
||||||
def __deepcopy__(self, memo):
|
def __deepcopy__(self, memo):
|
||||||
|
@ -534,8 +535,11 @@ cdef class Delegate(Provider):
|
||||||
if copied is not None:
|
if copied is not None:
|
||||||
return copied
|
return copied
|
||||||
|
|
||||||
copied = self.__class__(deepcopy(self.__provides, memo))
|
copied = self.__class__()
|
||||||
|
memo[id(self)] = copied
|
||||||
|
|
||||||
|
if self.provides:
|
||||||
|
copied.set_provides(deepcopy(self.provides, memo))
|
||||||
self._copy_overridings(copied, memo)
|
self._copy_overridings(copied, memo)
|
||||||
|
|
||||||
return copied
|
return copied
|
||||||
|
@ -556,9 +560,13 @@ cdef class Delegate(Provider):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def provides(self):
|
def provides(self):
|
||||||
"""Return provider."""
|
|
||||||
return self.__provides
|
return self.__provides
|
||||||
|
|
||||||
|
def set_provides(self, provides):
|
||||||
|
if provides:
|
||||||
|
provides = ensure_is_provider(provides)
|
||||||
|
self.__provides = provides
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def related(self):
|
def related(self):
|
||||||
"""Return related providers generator."""
|
"""Return related providers generator."""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user