python-injection 0.10.7__py3-none-any.whl → 0.10.8__py3-none-any.whl

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.
injection/__init__.pyi CHANGED
@@ -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
injection/_core/module.py CHANGED
@@ -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.inject(wp, return_factory=True) if inject else wp
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 not return_factory and isclass(wp):
549
+ if isclass(wp):
556
550
  wp.__init__ = self.inject(wp.__init__)
557
551
  return wp
558
552
 
559
- injected = Injected(wp)
553
+ return self.make_injected_function(wp)
560
554
 
561
- @injected.on_setup
562
- def listen() -> None:
563
- injected.update(self)
564
- self.add_listener(injected)
555
+ return decorator(wrapped) if wrapped else decorator
565
556
 
566
- return InjectedFunction(injected)
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
- return decorator(wrapped) if wrapped else decorator
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
  Metadata-Version: 2.1
2
2
  Name: python-injection
3
- Version: 0.10.7
3
+ Version: 0.10.8
4
4
  Summary: Fast and easy dependency injection framework.
5
5
  Home-page: https://github.com/100nm/python-injection
6
6
  License: MIT
@@ -1,5 +1,5 @@
1
1
  injection/__init__.py,sha256=6zHo40kXRsCruG23gMllEymAQ3crQkE_8Q-wV78iomU,769
2
- injection/__init__.pyi,sha256=CUugIRtmTKXyTbE3ox5grP7pX6zaBksbCWR5mKOwNCE,7042
2
+ injection/__init__.pyi,sha256=U0QxTtcDon_eY_AqDxRx5n-ui4QDm8DGolxtdjOVGbg,7169
3
3
  injection/_core/__init__.py,sha256=VMGLfdu0gYh82mt7zS297rQ7CE_gHVy0gRdI8RY_ZLY,1361
4
4
  injection/_core/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  injection/_core/common/event.py,sha256=JYwe528g0uzUSo7l-iXjzuziYk4xlO6Cakkm83xkg38,1290
@@ -8,7 +8,7 @@ injection/_core/common/lazy.py,sha256=kCO1q4S6AdBhsP5RrihBJpgfeR4hxvMqSz1cpCgBdj
8
8
  injection/_core/common/threading.py,sha256=OXm7L3p8c7O7eSkU-RTR7cobqIGMhuo-7gpDXsWKDNQ,214
9
9
  injection/_core/common/type.py,sha256=TQTD-f_rnAHS0VgfkWxNFU8HAWPvkAktNDQ9_23JLHM,1705
10
10
  injection/_core/hook.py,sha256=p9pC1zb9tDZykHs5HGM5VpRxWyvuajC45vilvkvatkY,2999
11
- injection/_core/module.py,sha256=eXasRKjT-gNyM6-UhN8UN-EsQy56sREMZ0UVTpNq4SM,25031
11
+ injection/_core/module.py,sha256=ckiLJR3oMf5V2Iy4q0Ywz9vnqMpL7nzViKS-aDBUDLU,25087
12
12
  injection/exceptions.py,sha256=-5Shs7R5rctQXhpMLfcjiMBCzrtFWxC88qETUIHz57s,692
13
13
  injection/integrations/__init__.py,sha256=NYLcstr4ESdLj326LlDub143z6JGM1z1pCOVWhBXK10,304
14
14
  injection/integrations/blacksheep.py,sha256=yO5gLb_l4W3bNPFt-v2qWIL9R8PNon4JmOxQEHdi-5o,923
@@ -17,6 +17,6 @@ injection/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  injection/testing/__init__.py,sha256=-C38gmZJwDtLDAWJhqiaosOZWQZwwFa1M34tODcrASs,747
18
18
  injection/testing/__init__.pyi,sha256=6ZXbbS-9ppMdkxd03I6yBNurmR3Xw7sM_qiokibkLeY,386
19
19
  injection/utils.py,sha256=gPcxGIdrGz4irbJXGTYPw33jNy8jg56u_c61eb1MBSE,1971
20
- python_injection-0.10.7.dist-info/METADATA,sha256=7DJYzpcPRTbBYtch0jct28aIqjvjqmLMLXPhhVKSavM,3059
21
- python_injection-0.10.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
22
- python_injection-0.10.7.dist-info/RECORD,,
20
+ python_injection-0.10.8.dist-info/METADATA,sha256=2xrqxqIAR0aTbYYxHY0a42OaGSKXRAiGDtoK2Yki7-U,3059
21
+ python_injection-0.10.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
22
+ python_injection-0.10.8.dist-info/RECORD,,