Skip to content

Commit

Permalink
Merge branch 'release/4.30.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
rmk135 committed Mar 20, 2021
2 parents ee89476 + 9ea8709 commit 8cad8c6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
4 changes: 4 additions & 0 deletions docs/main/changelog.rst
Expand Up @@ -7,6 +7,10 @@ that were made in every particular version.
From version 0.7.6 *Dependency Injector* framework strictly
follows `Semantic versioning`_

4.30.0
------
- Remove restriction to wire a dynamic container.

4.29.2
------
- Fix wiring to not crash on missing signatures.
Expand Down
2 changes: 1 addition & 1 deletion src/dependency_injector/__init__.py
@@ -1,6 +1,6 @@
"""Top-level package."""

__version__ = '4.29.2'
__version__ = '4.30.0'
"""Version number.
:type: str
Expand Down
9 changes: 0 additions & 9 deletions src/dependency_injector/wiring.py
Expand Up @@ -322,9 +322,6 @@ def wire( # noqa: C901
packages: Optional[Iterable[ModuleType]] = None,
) -> None:
"""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:
modules = []

Expand Down Expand Up @@ -655,12 +652,6 @@ def _is_patched(fn):
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:
return (isinstance(instance, type)
and getattr(instance, '__IS_CONTAINER__', False) is True
Expand Down
23 changes: 22 additions & 1 deletion tests/unit/wiring/test_wiring_string_ids_py36.py
Expand Up @@ -7,7 +7,7 @@
Provider,
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
import os
Expand Down Expand Up @@ -335,6 +335,27 @@ def test_closing_resource_bypass_marker_injection(self):
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):

def test_async_injections(self):
Expand Down

0 comments on commit 8cad8c6

Please sign in to comment.