python-injection 0.12.2__py3-none-any.whl → 0.12.3__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/_core/common/asynchronous.py +12 -5
- injection/_core/module.py +2 -2
- {python_injection-0.12.2.dist-info → python_injection-0.12.3.dist-info}/METADATA +1 -1
- {python_injection-0.12.2.dist-info → python_injection-0.12.3.dist-info}/RECORD +5 -5
- {python_injection-0.12.2.dist-info → python_injection-0.12.3.dist-info}/WHEEL +0 -0
@@ -1,7 +1,8 @@
|
|
1
|
+
import asyncio
|
1
2
|
from abc import abstractmethod
|
2
3
|
from collections.abc import Awaitable, Callable, Generator
|
3
4
|
from dataclasses import dataclass
|
4
|
-
from typing import Any,
|
5
|
+
from typing import Any, Protocol, runtime_checkable
|
5
6
|
|
6
7
|
|
7
8
|
@dataclass(repr=False, eq=False, frozen=True, slots=True)
|
@@ -32,10 +33,16 @@ class AsyncCaller[**P, T](Caller[P, T]):
|
|
32
33
|
async def acall(self, /, *args: P.args, **kwargs: P.kwargs) -> T:
|
33
34
|
return await self.callable(*args, **kwargs)
|
34
35
|
|
35
|
-
def call(self, /, *args: P.args, **kwargs: P.kwargs) ->
|
36
|
-
|
37
|
-
|
38
|
-
)
|
36
|
+
def call(self, /, *args: P.args, **kwargs: P.kwargs) -> T:
|
37
|
+
loop = asyncio.get_event_loop()
|
38
|
+
|
39
|
+
if loop.is_running():
|
40
|
+
raise RuntimeError(
|
41
|
+
"Can't call an asynchronous function in a synchronous context."
|
42
|
+
)
|
43
|
+
|
44
|
+
coroutine = self.callable(*args, **kwargs)
|
45
|
+
return loop.run_until_complete(coroutine)
|
39
46
|
|
40
47
|
|
41
48
|
@dataclass(repr=False, eq=False, frozen=True, slots=True)
|
injection/_core/module.py
CHANGED
@@ -78,8 +78,8 @@ class LocatorDependenciesUpdated[T](LocatorEvent):
|
|
78
78
|
length = len(self.classes)
|
79
79
|
formatted_types = ", ".join(f"`{cls}`" for cls in self.classes)
|
80
80
|
return (
|
81
|
-
f"{length} dependenc{
|
82
|
-
f"updated{f
|
81
|
+
f"{length} dependenc{'ies' if length > 1 else 'y'} have been "
|
82
|
+
f"updated{f': {formatted_types}' if formatted_types else ''}."
|
83
83
|
)
|
84
84
|
|
85
85
|
|
@@ -2,7 +2,7 @@ injection/__init__.py,sha256=1MI9kXuQfsqLGQK_5-Zm4JjecqopjGNlhsAW8iihn9M,919
|
|
2
2
|
injection/__init__.pyi,sha256=Gwtvo6sJVizqz0pTKNaG-Jz_NW0gSqEsoZF7T6p3V1s,8820
|
3
3
|
injection/_core/__init__.py,sha256=XERocCxCZBxPGIaOR37yeiQOZyvjHQ6a4rgRmlkUSuU,1367
|
4
4
|
injection/_core/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
injection/_core/common/asynchronous.py,sha256=
|
5
|
+
injection/_core/common/asynchronous.py,sha256=Sd7r5y42WSNXRtC4NvYRn5y2Jb6nNapj0aAOvkS4WIU,1726
|
6
6
|
injection/_core/common/event.py,sha256=kev8WUESAXzMn11EJsbTcICaCvYiD556E6BOLvQ54s4,1243
|
7
7
|
injection/_core/common/invertible.py,sha256=YZlAdh6bNJgf1-74TRjwJTm8xrlgY95ZhOUGLSJ4XcY,482
|
8
8
|
injection/_core/common/lazy.py,sha256=ZKx2O9CCFsF9F0SLM4zb7jSLksJUv-FBLCPlWltMN5k,1398
|
@@ -11,7 +11,7 @@ injection/_core/common/type.py,sha256=c4QfvbkMfYMlNxqt-vq6QJ83ubMnw6AIVI2Rp-tV1P
|
|
11
11
|
injection/_core/descriptors.py,sha256=y1rFTQdCDIMLVQfuQE8ZkTPlVZKgzvwZ2Y20Si05DwM,662
|
12
12
|
injection/_core/hook.py,sha256=Qv505pr3kjOE6UitftlLh9JKX9OCNqZBRtHbFha1gqM,3130
|
13
13
|
injection/_core/injectables.py,sha256=rBcrTYRpZ69LkHSGm6bve6TGPwf66XkuK2XVACwcRNc,2427
|
14
|
-
injection/_core/module.py,sha256=
|
14
|
+
injection/_core/module.py,sha256=e0FVvhplVRbOGrAT-RCNKIR2pTng5qEAxCjuurm0cEA,28675
|
15
15
|
injection/exceptions.py,sha256=-5Shs7R5rctQXhpMLfcjiMBCzrtFWxC88qETUIHz57s,692
|
16
16
|
injection/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
17
|
injection/integrations/fastapi.py,sha256=tI9ohXOm_WucqkS-DZJceIVb_mE9LOY_UpIcr6hfRVM,1668
|
@@ -19,6 +19,6 @@ injection/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
19
|
injection/testing/__init__.py,sha256=Wd9sq43CJCV7GjYFSIaikIf4hJ5lfVNS7GP3iI8a1X8,719
|
20
20
|
injection/testing/__init__.pyi,sha256=Dyf1LjSj3LrjghXjM2xkMiINg-OPWQMtjCEnnfWzaDY,372
|
21
21
|
injection/utils.py,sha256=a9y95B08Fr9IgDiBffeQdcawQcvAs5gwBDt9cCYX0uE,3061
|
22
|
-
python_injection-0.12.
|
23
|
-
python_injection-0.12.
|
24
|
-
python_injection-0.12.
|
22
|
+
python_injection-0.12.3.dist-info/METADATA,sha256=8AyuGaX3P5JfCRxQBcnMrwkssXYeKP52UC64xJ5XE-o,2958
|
23
|
+
python_injection-0.12.3.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
|
24
|
+
python_injection-0.12.3.dist-info/RECORD,,
|
File without changes
|