File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
samples/wiringfastdepends Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 3
3
from dependency_injector import containers , providers
4
4
from dependency_injector .wiring import inject , Provide
5
5
from fast_depends import Depends
6
+ from typing_extensions import Annotated
6
7
7
8
8
9
class CoefficientService :
@@ -23,5 +24,13 @@ def apply_coefficient(
23
24
return a * coefficient_provider .get_coefficient ()
24
25
25
26
27
+ @inject
28
+ def apply_coefficient_annotated (
29
+ a : int ,
30
+ coefficient_provider : Annotated [CoefficientService , Depends (Provide [Container .service ])],
31
+ ) -> float :
32
+ return a * coefficient_provider .get_coefficient ()
33
+
34
+
26
35
container = Container ()
27
36
container .wire (modules = [sys .modules [__name__ ]])
Original file line number Diff line number Diff line change 3
3
from wiringfastdepends import sample
4
4
5
5
6
- def test_apply_coefficient ():
7
- assert sample .apply_coefficient (100 ) == 120.0
6
+ def test_apply_coefficient () -> None :
7
+ assert sample .apply_coefficient (100 ) == 120.0
8
+
9
+
10
+ def test_apply_coefficient_annotated () -> None :
11
+ assert sample .apply_coefficient_annotated (100 ) == 120.0
You can’t perform that action at this time.
0 commit comments