mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-25 11:04:01 +03:00
Merge branch 'release/4.31.2' into master
This commit is contained in:
commit
155f598699
|
@ -16,3 +16,4 @@ Dependency Injector Contributors
|
||||||
+ Dmitry Rassoshenko (rda-dev)
|
+ Dmitry Rassoshenko (rda-dev)
|
||||||
+ Fotis Koutoupas (kootoopas)
|
+ Fotis Koutoupas (kootoopas)
|
||||||
+ Shubhendra Singh Chauhan (withshubh)
|
+ Shubhendra Singh Chauhan (withshubh)
|
||||||
|
+ sonthonaxrk (sonthonaxrk)
|
||||||
|
|
|
@ -7,6 +7,15 @@ that were made in every particular version.
|
||||||
From version 0.7.6 *Dependency Injector* framework strictly
|
From version 0.7.6 *Dependency Injector* framework strictly
|
||||||
follows `Semantic versioning`_
|
follows `Semantic versioning`_
|
||||||
|
|
||||||
|
4.31.2
|
||||||
|
------
|
||||||
|
- Fix an issue with ``Dict`` provider non-string keys.
|
||||||
|
See issue: `#435 <https://github.com/ets-labs/python-dependency-injector/issues/435>`_.
|
||||||
|
Thanks to `@daniel55411 <https://github.com/daniel55411>`_ for reporting the issue.
|
||||||
|
- Fix Flask scoped contexts example.
|
||||||
|
See issue: `#440 <https://github.com/ets-labs/python-dependency-injector/pull/440>`_.
|
||||||
|
Thanks to `@sonthonaxrk <https://github.com/sonthonaxrk>`_ for the contribution.
|
||||||
|
|
||||||
4.31.1
|
4.31.1
|
||||||
------
|
------
|
||||||
- Fix ``ThreadSafeSingleton`` synchronization issue.
|
- Fix ``ThreadSafeSingleton`` synchronization issue.
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Service:
|
||||||
|
|
||||||
class Container(containers.DeclarativeContainer):
|
class Container(containers.DeclarativeContainer):
|
||||||
|
|
||||||
service_provider = providers.Singleton(Service)
|
service_provider = providers.ThreadLocalSingleton(Service)
|
||||||
|
|
||||||
|
|
||||||
def index_view():
|
def index_view():
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Top-level package."""
|
"""Top-level package."""
|
||||||
|
|
||||||
__version__ = '4.31.1'
|
__version__ = '4.31.2'
|
||||||
"""Version number.
|
"""Version number.
|
||||||
|
|
||||||
:type: str
|
:type: str
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3169,7 +3169,7 @@ cdef class Dict(Provider):
|
||||||
return copied
|
return copied
|
||||||
|
|
||||||
copied = _memorized_duplicate(self, memo)
|
copied = _memorized_duplicate(self, memo)
|
||||||
copied.set_kwargs(**deepcopy(self.kwargs, memo))
|
self._copy_kwargs(copied, memo)
|
||||||
self._copy_overridings(copied, memo)
|
self._copy_overridings(copied, memo)
|
||||||
return copied
|
return copied
|
||||||
|
|
||||||
|
@ -3238,11 +3238,20 @@ cdef class Dict(Provider):
|
||||||
yield from filter(is_provider, self.kwargs.values())
|
yield from filter(is_provider, self.kwargs.values())
|
||||||
yield from super().related
|
yield from super().related
|
||||||
|
|
||||||
|
def _copy_kwargs(self, copied, memo):
|
||||||
|
"""Return copy of kwargs."""
|
||||||
|
copied_kwargs = {
|
||||||
|
_copy_if_provider(name, memo): _copy_if_provider(value, memo)
|
||||||
|
for name, value in self.kwargs.items()
|
||||||
|
}
|
||||||
|
copied.set_kwargs(copied_kwargs)
|
||||||
|
|
||||||
cpdef object _provide(self, tuple args, dict kwargs):
|
cpdef object _provide(self, tuple args, dict kwargs):
|
||||||
"""Return result of provided callable's call."""
|
"""Return result of provided callable's call."""
|
||||||
return __provide_keyword_args(kwargs, self.__kwargs, self.__kwargs_len)
|
return __provide_keyword_args(kwargs, self.__kwargs, self.__kwargs_len)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cdef class Resource(Provider):
|
cdef class Resource(Provider):
|
||||||
"""Resource provider provides a component with initialization and shutdown."""
|
"""Resource provider provides a component with initialization and shutdown."""
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,27 @@ class DictTests(unittest.TestCase):
|
||||||
self.assertIs(dependent_provider2.cls, dependent_provider_copy2.cls)
|
self.assertIs(dependent_provider2.cls, dependent_provider_copy2.cls)
|
||||||
self.assertIsNot(dependent_provider2, dependent_provider_copy2)
|
self.assertIsNot(dependent_provider2, dependent_provider_copy2)
|
||||||
|
|
||||||
|
def test_deepcopy_kwargs_non_string_keys(self):
|
||||||
|
a1 = object()
|
||||||
|
a2 = object()
|
||||||
|
|
||||||
|
dependent_provider1 = providers.Factory(list)
|
||||||
|
dependent_provider2 = providers.Factory(dict)
|
||||||
|
|
||||||
|
provider = providers.Dict({a1: dependent_provider1, a2: dependent_provider2})
|
||||||
|
|
||||||
|
provider_copy = providers.deepcopy(provider)
|
||||||
|
dependent_provider_copy1 = provider_copy.kwargs[a1]
|
||||||
|
dependent_provider_copy2 = provider_copy.kwargs[a2]
|
||||||
|
|
||||||
|
self.assertNotEqual(provider.kwargs, provider_copy.kwargs)
|
||||||
|
|
||||||
|
self.assertIs(dependent_provider1.cls, dependent_provider_copy1.cls)
|
||||||
|
self.assertIsNot(dependent_provider1, dependent_provider_copy1)
|
||||||
|
|
||||||
|
self.assertIs(dependent_provider2.cls, dependent_provider_copy2.cls)
|
||||||
|
self.assertIsNot(dependent_provider2, dependent_provider_copy2)
|
||||||
|
|
||||||
def test_deepcopy_overridden(self):
|
def test_deepcopy_overridden(self):
|
||||||
provider = providers.Dict()
|
provider = providers.Dict()
|
||||||
object_provider = providers.Object(object())
|
object_provider = providers.Object(object())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user