mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-10-30 23:47:40 +03:00 
			
		
		
		
	Merge branch 'release/4.16.0' into master
This commit is contained in:
		
						commit
						a1f779a9f3
					
				|  | @ -7,6 +7,13 @@ 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.16.0 | ||||||
|  | ------ | ||||||
|  | - Add container base class ``containers.Container``. ``DynamicContainer`` | ||||||
|  |   and ``DeclarativeContainer`` become subclasses of the ``Container``. | ||||||
|  |   See issue: `#386 <https://github.com/ets-labs/python-dependency-injector/issues/386>`_. | ||||||
|  |   Thanks to `@ventaquil <https://github.com/ventaquil>`_ for reporting the issue. | ||||||
|  | 
 | ||||||
| 4.15.0 | 4.15.0 | ||||||
| ------ | ------ | ||||||
| - Add ``Configuration.from_pydantic()`` method to load configuration from a ``pydantic`` settings. | - Add ``Configuration.from_pydantic()`` method to load configuration from a ``pydantic`` settings. | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| """Top-level package.""" | """Top-level package.""" | ||||||
| 
 | 
 | ||||||
| __version__ = '4.15.0' | __version__ = '4.16.0' | ||||||
| """Version number. | """Version number. | ||||||
| 
 | 
 | ||||||
| :type: str | :type: str | ||||||
|  |  | ||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							|  | @ -23,7 +23,11 @@ else: | ||||||
|         raise NotImplementedError('Wiring requires Python 3.6 or above') |         raise NotImplementedError('Wiring requires Python 3.6 or above') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class DynamicContainer(object): | class Container(object): | ||||||
|  |     """Abstract container.""" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class DynamicContainer(Container): | ||||||
|     """Dynamic inversion of control container. |     """Dynamic inversion of control container. | ||||||
| 
 | 
 | ||||||
|     .. code-block:: python |     .. code-block:: python | ||||||
|  | @ -370,7 +374,7 @@ class DeclarativeContainerMetaClass(type): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @six.add_metaclass(DeclarativeContainerMetaClass) | @six.add_metaclass(DeclarativeContainerMetaClass) | ||||||
| class DeclarativeContainer(object): | class DeclarativeContainer(Container): | ||||||
|     """Declarative inversion of control container. |     """Declarative inversion of control container. | ||||||
| 
 | 
 | ||||||
|     .. code-block:: python |     .. code-block:: python | ||||||
|  |  | ||||||
|  | @ -48,3 +48,11 @@ class Container5(containers.DeclarativeContainer): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| dependencies: Dict[str, providers.Provider] = Container5.dependencies | dependencies: Dict[str, providers.Provider] = Container5.dependencies | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # Test 6: to check base class | ||||||
|  | class Container6(containers.DeclarativeContainer): | ||||||
|  |     provider = providers.Factory(int) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | container6: containers.Container = Container6() | ||||||
|  |  | ||||||
|  | @ -22,3 +22,6 @@ container4.set_providers(a=providers.Provider()) | ||||||
| # Test 5: to check .dependencies attribute | # Test 5: to check .dependencies attribute | ||||||
| container5 = containers.DynamicContainer() | container5 = containers.DynamicContainer() | ||||||
| dependencies: Dict[str, providers.Provider] = container5.dependencies | dependencies: Dict[str, providers.Provider] = container5.dependencies | ||||||
|  | 
 | ||||||
|  | # Test 6: to check base class | ||||||
|  | container6: containers.Container = containers.DynamicContainer() | ||||||
|  |  | ||||||
							
								
								
									
										18
									
								
								tests/unit/containers/test_types_py36.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								tests/unit/containers/test_types_py36.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | ||||||
|  | import unittest | ||||||
|  | 
 | ||||||
|  | from dependency_injector import containers | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class SomeClass: | ||||||
|  |     ... | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class TypesTest(unittest.TestCase): | ||||||
|  | 
 | ||||||
|  |     def test_declarative(self): | ||||||
|  |         container: containers.Container = containers.DeclarativeContainer() | ||||||
|  |         self.assertIsInstance(container, containers.Container) | ||||||
|  | 
 | ||||||
|  |     def test_dynamic(self): | ||||||
|  |         container: containers.Container = containers.DynamicContainer() | ||||||
|  |         self.assertIsInstance(container, containers.Container) | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user