Skip to content

Commit a1f779a

Browse files
committed
Merge branch 'release/4.16.0' into master
2 parents 6cc1a0c + 892330f commit a1f779a

File tree

7 files changed

+1484
-1417
lines changed

7 files changed

+1484
-1417
lines changed

docs/main/changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ that were made in every particular version.
77
From version 0.7.6 *Dependency Injector* framework strictly
88
follows `Semantic versioning`_
99

10+
4.16.0
11+
------
12+
- Add container base class ``containers.Container``. ``DynamicContainer``
13+
and ``DeclarativeContainer`` become subclasses of the ``Container``.
14+
See issue: `#386 <https://github.com/ets-labs/python-dependency-injector/issues/386>`_.
15+
Thanks to `@ventaquil <https://github.com/ventaquil>`_ for reporting the issue.
16+
1017
4.15.0
1118
------
1219
- Add ``Configuration.from_pydantic()`` method to load configuration from a ``pydantic`` settings.

src/dependency_injector/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Top-level package."""
22

3-
__version__ = '4.15.0'
3+
__version__ = '4.16.0'
44
"""Version number.
55
66
:type: str

src/dependency_injector/containers.c

Lines changed: 1441 additions & 1414 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dependency_injector/containers.pyx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ else:
2323
raise NotImplementedError('Wiring requires Python 3.6 or above')
2424

2525

26-
class DynamicContainer(object):
26+
class Container(object):
27+
"""Abstract container."""
28+
29+
30+
class DynamicContainer(Container):
2731
"""Dynamic inversion of control container.
2832
2933
.. code-block:: python
@@ -370,7 +374,7 @@ class DeclarativeContainerMetaClass(type):
370374

371375

372376
@six.add_metaclass(DeclarativeContainerMetaClass)
373-
class DeclarativeContainer(object):
377+
class DeclarativeContainer(Container):
374378
"""Declarative inversion of control container.
375379
376380
.. code-block:: python

tests/typing/declarative_container.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,11 @@ class Container5(containers.DeclarativeContainer):
4848

4949

5050
dependencies: Dict[str, providers.Provider] = Container5.dependencies
51+
52+
53+
# Test 6: to check base class
54+
class Container6(containers.DeclarativeContainer):
55+
provider = providers.Factory(int)
56+
57+
58+
container6: containers.Container = Container6()

tests/typing/dynamic_container.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@
2222
# Test 5: to check .dependencies attribute
2323
container5 = containers.DynamicContainer()
2424
dependencies: Dict[str, providers.Provider] = container5.dependencies
25+
26+
# Test 6: to check base class
27+
container6: containers.Container = containers.DynamicContainer()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import unittest
2+
3+
from dependency_injector import containers
4+
5+
6+
class SomeClass:
7+
...
8+
9+
10+
class TypesTest(unittest.TestCase):
11+
12+
def test_declarative(self):
13+
container: containers.Container = containers.DeclarativeContainer()
14+
self.assertIsInstance(container, containers.Container)
15+
16+
def test_dynamic(self):
17+
container: containers.Container = containers.DynamicContainer()
18+
self.assertIsInstance(container, containers.Container)

0 commit comments

Comments
 (0)