File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -1390,7 +1390,7 @@ def provide_strs_also(self) -> List[str]:
13901390def _mark_provider_function (function : Callable , * , allow_multi : bool ) -> None :
13911391 scope_ = getattr (function , '__scope__' , None )
13921392 try :
1393- annotations = get_type_hints (function )
1393+ annotations = get_type_hints (function , include_extras = True )
13941394 except NameError :
13951395 return_type = '__deferred__'
13961396 else :
Original file line number Diff line number Diff line change @@ -2032,3 +2032,19 @@ class MyClass:
20322032 injector = Injector ([configure ])
20332033 instance = injector .get (MyClass )
20342034 assert instance .foo == 123
2035+
2036+
2037+ def test_module_provider_with_annotated ():
2038+ class MyModule (Module ):
2039+ @provider
2040+ def provide_first (self ) -> Annotated [str , 'first' ]:
2041+ return 'Bob'
2042+
2043+ @provider
2044+ def provide_second (self ) -> Annotated [str , 'second' ]:
2045+ return 'Iger'
2046+
2047+ module = MyModule ()
2048+ injector = Injector (module )
2049+ assert injector .get (Annotated [str , 'first' ]) == 'Bob'
2050+ assert injector .get (Annotated [str , 'second' ]) == 'Iger'
You can’t perform that action at this time.
0 commit comments