mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-02-22 22:53:00 +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.
|
||||
|
||||
.. note::
|
||||
Python has a limitation on patching already imported individual members. To protect from errors
|
||||
prefer an import of modules instead of individual members or make sure that imports happen
|
||||
Python has a limitation on patching individually imported functions. To protect from errors
|
||||
prefer importing modules to importing individual functions or make sure imports happen
|
||||
after the wiring:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from . import module
|
||||
|
||||
module.fn()
|
||||
|
||||
# instead of
|
||||
# Potential error:
|
||||
|
||||
from .module import fn
|
||||
|
||||
fn()
|
||||
|
||||
Instead use next:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Always works:
|
||||
|
||||
from . import module
|
||||
|
||||
module.fn()
|
||||
|
||||
Integration with other frameworks
|
||||
---------------------------------
|
||||
|
||||
|
@ -211,5 +217,6 @@ Take a look at other application examples:
|
|||
- :ref:`aiohttp-example`
|
||||
- :ref:`sanic-example`
|
||||
- :ref:`fastapi-example`
|
||||
- :ref:`fastapi-redis-example`
|
||||
|
||||
.. disqus::
|
||||
|
|
Loading…
Reference in New Issue
Block a user