File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -523,6 +523,10 @@ def _patch_method(
523523
524524 _bind_injections (fn , providers_map )
525525
526+ if fn is method :
527+ # Hotfix, see: https://github.com/ets-labs/python-dependency-injector/issues/884
528+ return
529+
526530 if isinstance (method , (classmethod , staticmethod )):
527531 fn = type (method )(fn )
528532
Original file line number Diff line number Diff line change 1+ from typing import Any , Iterator
2+
3+ from pytest import fixture
4+
5+ from dependency_injector .containers import DeclarativeContainer
6+ from dependency_injector .providers import Object
7+ from dependency_injector .wiring import Provide , inject
8+
9+
10+ class A :
11+ @inject
12+ def foo (self , value : str = Provide ["value" ]) -> str :
13+ return "A" + value
14+
15+
16+ class B (A ): ...
17+
18+
19+ class C (A ):
20+ def foo (self , * args : Any , ** kwargs : Any ) -> str :
21+ return "C" + super ().foo ()
22+
23+
24+ class D (B , C ): ...
25+
26+
27+ class Container (DeclarativeContainer ):
28+ value = Object ("X" )
29+
30+
31+ @fixture
32+ def container () -> Iterator [Container ]:
33+ c = Container ()
34+ c .wire (modules = [__name__ ])
35+ yield c
36+ c .unwire ()
37+
38+
39+ def test_preserve_mro (container : Container ) -> None :
40+ assert D ().foo () == "CAX"
You can’t perform that action at this time.
0 commit comments