From 4c039d012ef3415957249d4d87079a1780753df2 Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Tue, 29 Sep 2020 23:54:25 -0400 Subject: [PATCH] Add a note on individuals import to wiring docs --- docs/wiring.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/wiring.rst b/docs/wiring.rst index 671f5153..a3727331 100644 --- a/docs/wiring.rst +++ b/docs/wiring.rst @@ -153,6 +153,23 @@ You can use that in testing to re-create and re-wire a container before each tes Wiring can take time if you have a large codebase. Consider to persist a container instance and 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 + after the wiring: + + .. code-block:: python + + from . import module + + module.fn() + + # instead of + + from .module import fn + + fn() + Integration with other frameworks ---------------------------------