mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-04 12:23:14 +03:00
Add generic typing for @inject
This commit is contained in:
parent
a211d0291d
commit
ff29d84995
|
@ -28,6 +28,7 @@ __all__ = (
|
||||||
)
|
)
|
||||||
|
|
||||||
T = TypeVar('T')
|
T = TypeVar('T')
|
||||||
|
F = TypeVar('F', bound=Callable[..., Any])
|
||||||
Container = Any
|
Container = Any
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,7 +204,7 @@ def unwire(
|
||||||
_unpatch(member, method_name, method)
|
_unpatch(member, method_name, method)
|
||||||
|
|
||||||
|
|
||||||
def inject(fn: Callable[..., Any]) -> Callable[..., Any]:
|
def inject(fn: F) -> F:
|
||||||
"""Decorate callable with injecting decorator."""
|
"""Decorate callable with injecting decorator."""
|
||||||
reference_injections, reference_closing = _fetch_reference_injections(fn)
|
reference_injections, reference_closing = _fetch_reference_injections(fn)
|
||||||
return _get_patched(fn, reference_injections, reference_closing)
|
return _get_patched(fn, reference_injections, reference_closing)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user