mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-25 19:14:00 +03:00
Merge branch 'release/4.30.0' into master
This commit is contained in:
commit
8cad8c6b65
|
@ -7,6 +7,10 @@ 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.30.0
|
||||||
|
------
|
||||||
|
- Remove restriction to wire a dynamic container.
|
||||||
|
|
||||||
4.29.2
|
4.29.2
|
||||||
------
|
------
|
||||||
- Fix wiring to not crash on missing signatures.
|
- Fix wiring to not crash on missing signatures.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Top-level package."""
|
"""Top-level package."""
|
||||||
|
|
||||||
__version__ = '4.29.2'
|
__version__ = '4.30.0'
|
||||||
"""Version number.
|
"""Version number.
|
||||||
|
|
||||||
:type: str
|
:type: str
|
||||||
|
|
|
@ -322,9 +322,6 @@ def wire( # noqa: C901
|
||||||
packages: Optional[Iterable[ModuleType]] = None,
|
packages: Optional[Iterable[ModuleType]] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Wire container providers with provided packages and modules."""
|
"""Wire container providers with provided packages and modules."""
|
||||||
if not _is_declarative_container_instance(container):
|
|
||||||
raise Exception('Can wire only an instance of the declarative container')
|
|
||||||
|
|
||||||
if not modules:
|
if not modules:
|
||||||
modules = []
|
modules = []
|
||||||
|
|
||||||
|
@ -655,12 +652,6 @@ def _is_patched(fn):
|
||||||
return getattr(fn, '__wired__', False) is True
|
return getattr(fn, '__wired__', False) is True
|
||||||
|
|
||||||
|
|
||||||
def _is_declarative_container_instance(instance: Any) -> bool:
|
|
||||||
return (not isinstance(instance, type)
|
|
||||||
and getattr(instance, '__IS_CONTAINER__', False) is True
|
|
||||||
and getattr(instance, 'declarative_parent', None) is not None)
|
|
||||||
|
|
||||||
|
|
||||||
def _is_declarative_container(instance: Any) -> bool:
|
def _is_declarative_container(instance: Any) -> bool:
|
||||||
return (isinstance(instance, type)
|
return (isinstance(instance, type)
|
||||||
and getattr(instance, '__IS_CONTAINER__', False) is True
|
and getattr(instance, '__IS_CONTAINER__', False) is True
|
||||||
|
|
|
@ -7,7 +7,7 @@ from dependency_injector.wiring import (
|
||||||
Provider,
|
Provider,
|
||||||
Closing,
|
Closing,
|
||||||
)
|
)
|
||||||
from dependency_injector import errors
|
from dependency_injector import containers, providers, errors
|
||||||
|
|
||||||
# Runtime import to avoid syntax errors in samples on Python < 3.5
|
# Runtime import to avoid syntax errors in samples on Python < 3.5
|
||||||
import os
|
import os
|
||||||
|
@ -335,6 +335,27 @@ class WiringAndFastAPITest(unittest.TestCase):
|
||||||
self.assertIsNot(result_1, result_2)
|
self.assertIsNot(result_1, result_2)
|
||||||
|
|
||||||
|
|
||||||
|
class WireDynamicContainerTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_wire(self):
|
||||||
|
sub = containers.DynamicContainer()
|
||||||
|
sub.int_object = providers.Object(1)
|
||||||
|
|
||||||
|
container = containers.DynamicContainer()
|
||||||
|
container.config = providers.Configuration()
|
||||||
|
container.service = providers.Factory(Service)
|
||||||
|
container.sub = sub
|
||||||
|
|
||||||
|
container.wire(
|
||||||
|
modules=[module],
|
||||||
|
packages=[package],
|
||||||
|
)
|
||||||
|
self.addCleanup(container.unwire)
|
||||||
|
|
||||||
|
service = module.test_function()
|
||||||
|
self.assertIsInstance(service, Service)
|
||||||
|
|
||||||
|
|
||||||
class WiringAsyncInjectionsTest(AsyncTestCase):
|
class WiringAsyncInjectionsTest(AsyncTestCase):
|
||||||
|
|
||||||
def test_async_injections(self):
|
def test_async_injections(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user