File tree 4 files changed +27
-11
lines changed
4 files changed +27
-11
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ that were made in every particular version.
7
7
From version 0.7.6 *Dependency Injector * framework strictly
8
8
follows `Semantic versioning `_
9
9
10
+ 4.30.0
11
+ ------
12
+ - Remove restriction to wire a dynamic container.
13
+
10
14
4.29.2
11
15
------
12
16
- Fix wiring to not crash on missing signatures.
Original file line number Diff line number Diff line change 1
1
"""Top-level package."""
2
2
3
- __version__ = '4.29.2 '
3
+ __version__ = '4.30.0 '
4
4
"""Version number.
5
5
6
6
:type: str
Original file line number Diff line number Diff line change @@ -322,9 +322,6 @@ def wire( # noqa: C901
322
322
packages : Optional [Iterable [ModuleType ]] = None ,
323
323
) -> None :
324
324
"""Wire container providers with provided packages and modules."""
325
- if not _is_declarative_container_instance (container ):
326
- raise Exception ('Can wire only an instance of the declarative container' )
327
-
328
325
if not modules :
329
326
modules = []
330
327
@@ -655,12 +652,6 @@ def _is_patched(fn):
655
652
return getattr (fn , '__wired__' , False ) is True
656
653
657
654
658
- def _is_declarative_container_instance (instance : Any ) -> bool :
659
- return (not isinstance (instance , type )
660
- and getattr (instance , '__IS_CONTAINER__' , False ) is True
661
- and getattr (instance , 'declarative_parent' , None ) is not None )
662
-
663
-
664
655
def _is_declarative_container (instance : Any ) -> bool :
665
656
return (isinstance (instance , type )
666
657
and getattr (instance , '__IS_CONTAINER__' , False ) is True
Original file line number Diff line number Diff line change 7
7
Provider ,
8
8
Closing ,
9
9
)
10
- from dependency_injector import errors
10
+ from dependency_injector import containers , providers , errors
11
11
12
12
# Runtime import to avoid syntax errors in samples on Python < 3.5
13
13
import os
@@ -335,6 +335,27 @@ def test_closing_resource_bypass_marker_injection(self):
335
335
self .assertIsNot (result_1 , result_2 )
336
336
337
337
338
+ class WireDynamicContainerTest (unittest .TestCase ):
339
+
340
+ def test_wire (self ):
341
+ sub = containers .DynamicContainer ()
342
+ sub .int_object = providers .Object (1 )
343
+
344
+ container = containers .DynamicContainer ()
345
+ container .config = providers .Configuration ()
346
+ container .service = providers .Factory (Service )
347
+ container .sub = sub
348
+
349
+ container .wire (
350
+ modules = [module ],
351
+ packages = [package ],
352
+ )
353
+ self .addCleanup (container .unwire )
354
+
355
+ service = module .test_function ()
356
+ self .assertIsInstance (service , Service )
357
+
358
+
338
359
class WiringAsyncInjectionsTest (AsyncTestCase ):
339
360
340
361
def test_async_injections (self ):
You can’t perform that action at this time.
0 commit comments