Add @inject decorator

This commit is contained in:
Roman Mogylatov 2020-11-13 15:22:46 -05:00
parent b43c7017ee
commit f89a557759

View File

@ -21,6 +21,7 @@ from . import providers
__all__ = (
'wire',
'unwire',
'inject',
'Provide',
'Provider',
'Closing',
@ -202,6 +203,12 @@ def unwire(
_unpatch(member, method_name, method)
def inject(fn: Callable[..., Any]) -> Callable[..., Any]:
"""Decorate callable with injecting decorator."""
reference_injections, reference_closing = _fetch_reference_injections(fn)
return _get_patched(fn, reference_injections, reference_closing)
def _patch_fn(
module: ModuleType,
name: str,