mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-05-23 05:56:19 +03:00
Add @inject decorator
This commit is contained in:
parent
b43c7017ee
commit
f89a557759
|
@ -21,6 +21,7 @@ from . import providers
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'wire',
|
'wire',
|
||||||
'unwire',
|
'unwire',
|
||||||
|
'inject',
|
||||||
'Provide',
|
'Provide',
|
||||||
'Provider',
|
'Provider',
|
||||||
'Closing',
|
'Closing',
|
||||||
|
@ -202,6 +203,12 @@ def unwire(
|
||||||
_unpatch(member, method_name, method)
|
_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(
|
def _patch_fn(
|
||||||
module: ModuleType,
|
module: ModuleType,
|
||||||
name: str,
|
name: str,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user