Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion injector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ def provide_strs_also(self) -> List[str]:
def _mark_provider_function(function: Callable, *, allow_multi: bool) -> None:
scope_ = getattr(function, '__scope__', None)
try:
annotations = get_type_hints(function)
annotations = get_type_hints(function, include_extras=True)
except NameError:
return_type = '__deferred__'
else:
Expand Down
16 changes: 16 additions & 0 deletions injector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2032,3 +2032,19 @@ class MyClass:
injector = Injector([configure])
instance = injector.get(MyClass)
assert instance.foo == 123


def test_module_provider_with_annotated():
class MyModule(Module):
@provider
def provide_first(self) -> Annotated[str, 'first']:
return 'Bob'

@provider
def provide_second(self) -> Annotated[str, 'second']:
return 'Iger'

module = MyModule()
injector = Injector(module)
assert injector.get(Annotated[str, 'first']) == 'Bob'
assert injector.get(Annotated[str, 'second']) == 'Iger'