Add generic typing for @inject

This commit is contained in:
Roman Mogylatov 2020-11-13 17:07:40 -05:00
parent a211d0291d
commit ff29d84995

View File

@ -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)