modern-di 0.4.0__py3-none-any.whl → 0.4.1__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.
Potentially problematic release.
This version of modern-di might be problematic. Click here for more details.
- modern_di/providers/__init__.py +4 -0
- modern_di/providers/context_adapter.py +27 -0
- {modern_di-0.4.0.dist-info → modern_di-0.4.1.dist-info}/METADATA +1 -1
- {modern_di-0.4.0.dist-info → modern_di-0.4.1.dist-info}/RECORD +6 -5
- {modern_di-0.4.0.dist-info → modern_di-0.4.1.dist-info}/WHEEL +0 -0
- {modern_di-0.4.0.dist-info → modern_di-0.4.1.dist-info}/licenses/LICENSE +0 -0
modern_di/providers/__init__.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from modern_di.providers.abstract import AbstractProvider
|
|
2
|
+
from modern_di.providers.context_adapter import ContextAdapter
|
|
1
3
|
from modern_di.providers.dict import Dict
|
|
2
4
|
from modern_di.providers.factory import Factory
|
|
3
5
|
from modern_di.providers.list import List
|
|
@@ -7,6 +9,8 @@ from modern_di.providers.singleton import Singleton
|
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
__all__ = [
|
|
12
|
+
"AbstractProvider",
|
|
13
|
+
"ContextAdapter",
|
|
10
14
|
"Factory",
|
|
11
15
|
"Dict",
|
|
12
16
|
"List",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
import typing
|
|
3
|
+
|
|
4
|
+
from modern_di import Container
|
|
5
|
+
from modern_di.providers import AbstractProvider
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
T_co = typing.TypeVar("T_co", covariant=True)
|
|
9
|
+
P = typing.ParamSpec("P")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ContextAdapter(AbstractProvider[T_co]):
|
|
13
|
+
__slots__ = [*AbstractProvider.BASE_SLOTS, "_function"]
|
|
14
|
+
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
scope: enum.IntEnum,
|
|
18
|
+
function: typing.Callable[..., T_co],
|
|
19
|
+
) -> None:
|
|
20
|
+
super().__init__(scope)
|
|
21
|
+
self._function = function
|
|
22
|
+
|
|
23
|
+
async def async_resolve(self, container: Container) -> T_co:
|
|
24
|
+
return self._function(**container.find_container(self.scope).context)
|
|
25
|
+
|
|
26
|
+
def sync_resolve(self, container: Container) -> T_co:
|
|
27
|
+
return self._function(**container.find_container(self.scope).context)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: modern-di
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: Dependency Injection framework with IOC-container and scopes
|
|
5
5
|
Project-URL: repository, https://github.com/modern-python/modern-di
|
|
6
6
|
Project-URL: docs, https://modern-di.readthedocs.io
|
|
@@ -4,15 +4,16 @@ modern_di/graph.py,sha256=X60wtG3Mqus_5YZNiZlQuXoHODBp7rYl_IHJs7GzSQM,1356
|
|
|
4
4
|
modern_di/provider_state.py,sha256=5Bl_iYEpXjMqoWZJ4op2-axo4Z8nR_vYbLVHL_u5R0c,1206
|
|
5
5
|
modern_di/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
modern_di/scope.py,sha256=nnrTLnFT_dMDLVIwvJHcGlJsB2k1WIHusrRSGQIMEsg,97
|
|
7
|
-
modern_di/providers/__init__.py,sha256=
|
|
7
|
+
modern_di/providers/__init__.py,sha256=oeP3sKZJQF9COfT_YYJiLwiU3CbDfQMk4rzYHO52Xvg,555
|
|
8
8
|
modern_di/providers/abstract.py,sha256=UMj4CRn-JfGZfiveWFTkH7V92h4UXS4eYf8noZqPWGQ,3107
|
|
9
|
+
modern_di/providers/context_adapter.py,sha256=_b1x3ToQPWT-9KkDioFhw1W8Q1VXZYUnczfYzMTobVA,760
|
|
9
10
|
modern_di/providers/dict.py,sha256=nCU9iaqteYHDbILAfhrdnbMgS9_emE4MS7Xn2VoUlPo,858
|
|
10
11
|
modern_di/providers/factory.py,sha256=-QXh_qoJvYIY5kxKPkGYup5pqQvS9HSietI0MqKOb_Q,1185
|
|
11
12
|
modern_di/providers/list.py,sha256=3hx34RfBRmqzh-cT5D6wSTDJPkBGMK_ul4n9gQz-o9M,769
|
|
12
13
|
modern_di/providers/resource.py,sha256=nKy8_Wfn2cAIvlu_qGjGanmlgrkHQUsZxBNNR6p7OuE,3649
|
|
13
14
|
modern_di/providers/selector.py,sha256=RQbHD2-Liw-TGqu6UELbfCzXYuqxiO_Mg1tLyF3mKQo,1419
|
|
14
15
|
modern_di/providers/singleton.py,sha256=7XBNhVzhV5Rh_F7iWZx8is7i7_PuctQ9thKeqIkjnTs,1999
|
|
15
|
-
modern_di-0.4.
|
|
16
|
-
modern_di-0.4.
|
|
17
|
-
modern_di-0.4.
|
|
18
|
-
modern_di-0.4.
|
|
16
|
+
modern_di-0.4.1.dist-info/METADATA,sha256=0yPqoF0wEcJyXcot-4cdWj5SCAEyaGb5J9Np9GTvl5c,2767
|
|
17
|
+
modern_di-0.4.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
18
|
+
modern_di-0.4.1.dist-info/licenses/LICENSE,sha256=aA5_eJwDKqnGvL7PbkPb9x5f-VGIqZ9cvWWkeGqeD90,1070
|
|
19
|
+
modern_di-0.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|