Merge branch 'release/4.35.2' into master

This commit is contained in:
Roman Mogylatov 2021-08-06 16:50:53 -04:00
commit cde7dee4b3
4 changed files with 21 additions and 1 deletions

View File

@ -7,6 +7,12 @@ that were made in every particular version.
From version 0.7.6 *Dependency Injector* framework strictly
follows `Semantic versioning`_
4.35.2
------
- Update wiring to support modules provided as packages.
See issue `#481 <https://github.com/ets-labs/python-dependency-injector/issues/481>`_.
Thanks to `@Sadbot <https://github.com/Sadbot>`_ for demonstrating the issue.
4.35.1
------
- Fix a container issue with supporting custom string types.

View File

@ -1,6 +1,6 @@
"""Top-level package."""
__version__ = '4.35.1'
__version__ = '4.35.2'
"""Version number.
:type: str

View File

@ -552,6 +552,8 @@ def _unbind_injections(fn: Callable[..., Any]) -> None:
def _fetch_modules(package):
modules = [package]
if not hasattr(package, '__path__') or not hasattr(package, '__name__'):
return modules
for module_info in pkgutil.walk_packages(
path=package.__path__,
prefix=package.__name__ + '.',

View File

@ -310,6 +310,18 @@ class WiringTest(unittest.TestCase):
self.assertIsInstance(service, Service)
class ModuleAsPackagingTest(unittest.TestCase):
def setUp(self):
self.container = Container(config={'a': {'b': {'c': 10}}})
self.addCleanup(self.container.unwire)
def test_module_as_package_wiring(self):
# See: https://github.com/ets-labs/python-dependency-injector/issues/481
self.container.wire(packages=[module])
self.assertIsInstance(module.service, Service)
class WiringAndQueue(unittest.TestCase):
def test_wire_queue(self) -> None: