From 73263045d701bfdbac298c8749b471c0c5cca773 Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Sat, 9 Jan 2021 08:06:46 -0500 Subject: [PATCH] Refactor wiring docs --- docs/wiring.rst | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/wiring.rst b/docs/wiring.rst index b5ce31d8..f455dbe3 100644 --- a/docs/wiring.rst +++ b/docs/wiring.rst @@ -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::