python-injection 0.10.7__tar.gz → 0.10.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_injection-0.10.7 → python_injection-0.10.8}/PKG-INFO +1 -1
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/__init__.pyi +5 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/_core/module.py +17 -16
- {python_injection-0.10.7 → python_injection-0.10.8}/pyproject.toml +2 -2
- {python_injection-0.10.7 → python_injection-0.10.8}/README.md +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/__init__.py +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/_core/__init__.py +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/_core/common/__init__.py +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/_core/common/event.py +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/_core/common/invertible.py +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/_core/common/lazy.py +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/_core/common/threading.py +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/_core/common/type.py +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/_core/hook.py +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/exceptions.py +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/integrations/__init__.py +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/integrations/blacksheep.py +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/integrations/fastapi.py +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/py.typed +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/testing/__init__.py +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/testing/__init__.pyi +0 -0
- {python_injection-0.10.7 → python_injection-0.10.8}/injection/utils.py +0 -0
@@ -125,6 +125,11 @@ class Module:
|
|
125
125
|
that no dependencies are resolved, so the module doesn't need to be locked.
|
126
126
|
"""
|
127
127
|
|
128
|
+
def make_injected_function[**P, T](
|
129
|
+
self,
|
130
|
+
wrapped: Callable[P, T],
|
131
|
+
/,
|
132
|
+
) -> Callable[P, T]: ...
|
128
133
|
def find_instance[T](self, cls: _InputType[T]) -> T:
|
129
134
|
"""
|
130
135
|
Function used to retrieve an instance associated with the type passed in
|
@@ -477,7 +477,7 @@ class Module(Broker, EventListener):
|
|
477
477
|
mode: Mode | ModeStr = Mode.get_default(),
|
478
478
|
):
|
479
479
|
def decorator(wp): # type: ignore[no-untyped-def]
|
480
|
-
factory = self.
|
480
|
+
factory = self.make_injected_function(wp) if inject else wp
|
481
481
|
classes = get_return_types(wp, on)
|
482
482
|
updater = Updater(
|
483
483
|
factory=factory,
|
@@ -544,28 +544,29 @@ class Module(Broker, EventListener):
|
|
544
544
|
)
|
545
545
|
return self
|
546
546
|
|
547
|
-
def inject[**P, T]( # type: ignore[no-untyped-def]
|
548
|
-
self,
|
549
|
-
wrapped: Callable[P, T] | None = None,
|
550
|
-
/,
|
551
|
-
*,
|
552
|
-
return_factory: bool = False,
|
553
|
-
):
|
547
|
+
def inject[**P, T](self, wrapped: Callable[P, T] | None = None, /): # type: ignore[no-untyped-def]
|
554
548
|
def decorator(wp): # type: ignore[no-untyped-def]
|
555
|
-
if
|
549
|
+
if isclass(wp):
|
556
550
|
wp.__init__ = self.inject(wp.__init__)
|
557
551
|
return wp
|
558
552
|
|
559
|
-
|
553
|
+
return self.make_injected_function(wp)
|
560
554
|
|
561
|
-
|
562
|
-
def listen() -> None:
|
563
|
-
injected.update(self)
|
564
|
-
self.add_listener(injected)
|
555
|
+
return decorator(wrapped) if wrapped else decorator
|
565
556
|
|
566
|
-
|
557
|
+
def make_injected_function[**P, T](
|
558
|
+
self,
|
559
|
+
wrapped: Callable[P, T],
|
560
|
+
/,
|
561
|
+
) -> InjectedFunction[P, T]:
|
562
|
+
injected = Injected(wrapped)
|
567
563
|
|
568
|
-
|
564
|
+
@injected.on_setup
|
565
|
+
def listen() -> None:
|
566
|
+
injected.update(self)
|
567
|
+
self.add_listener(injected)
|
568
|
+
|
569
|
+
return InjectedFunction(injected)
|
569
570
|
|
570
571
|
def find_instance[T](self, cls: InputType[T]) -> T:
|
571
572
|
injectable = self[cls]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "python-injection"
|
3
|
-
version = "0.10.
|
3
|
+
version = "0.10.8"
|
4
4
|
description = "Fast and easy dependency injection framework."
|
5
5
|
license = "MIT"
|
6
6
|
authors = ["remimd"]
|
@@ -84,7 +84,7 @@ warn_required_dynamic_aliases = true
|
|
84
84
|
|
85
85
|
[tool.pytest.ini_options]
|
86
86
|
python_files = "test_*.py"
|
87
|
-
addopts = "
|
87
|
+
addopts = "--tb short --cov ./ --cov-report term-missing:skip-covered"
|
88
88
|
asyncio_default_fixture_loop_scope = "session"
|
89
89
|
asyncio_mode = "auto"
|
90
90
|
testpaths = "**/tests/"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|