mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-11-04 01:47:36 +03:00 
			
		
		
		
	Refactor wiring docs
This commit is contained in:
		
							parent
							
								
									d98185c114
								
							
						
					
					
						commit
						73263045d7
					
				| 
						 | 
					@ -167,22 +167,28 @@ You can use that in testing to re-create and re-wire a container before each tes
 | 
				
			||||||
   avoid re-wiring between tests.
 | 
					   avoid re-wiring between tests.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. note::
 | 
					.. note::
 | 
				
			||||||
   Python has a limitation on patching already imported individual members. To protect from errors
 | 
					   Python has a limitation on patching individually imported functions. To protect from errors
 | 
				
			||||||
   prefer an import of modules instead of individual members or make sure that imports happen
 | 
					   prefer importing modules to importing individual functions or make sure imports happen
 | 
				
			||||||
   after the wiring:
 | 
					   after the wiring:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   .. code-block:: python
 | 
					   .. code-block:: python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      from . import module
 | 
					      # Potential error:
 | 
				
			||||||
 | 
					 | 
				
			||||||
      module.fn()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      # instead of
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      from .module import fn
 | 
					      from .module import fn
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      fn()
 | 
					      fn()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Instead use next:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   .. code-block:: python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      # Always works:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      from . import module
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      module.fn()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Integration with other frameworks
 | 
					Integration with other frameworks
 | 
				
			||||||
---------------------------------
 | 
					---------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -211,5 +217,6 @@ Take a look at other application examples:
 | 
				
			||||||
- :ref:`aiohttp-example`
 | 
					- :ref:`aiohttp-example`
 | 
				
			||||||
- :ref:`sanic-example`
 | 
					- :ref:`sanic-example`
 | 
				
			||||||
- :ref:`fastapi-example`
 | 
					- :ref:`fastapi-example`
 | 
				
			||||||
 | 
					- :ref:`fastapi-redis-example`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. disqus::
 | 
					.. disqus::
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user