mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-05-22 21:46:17 +03:00
Add @inject decorator
This commit is contained in:
parent
b43c7017ee
commit
f89a557759
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user