modern-di-litestar 0.9.0__tar.gz → 1.0.0a0__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.
- {modern_di_litestar-0.9.0 → modern_di_litestar-1.0.0a0}/PKG-INFO +2 -2
- {modern_di_litestar-0.9.0 → modern_di_litestar-1.0.0a0}/modern_di_litestar/main.py +8 -7
- {modern_di_litestar-0.9.0 → modern_di_litestar-1.0.0a0}/pyproject.toml +2 -2
- {modern_di_litestar-0.9.0 → modern_di_litestar-1.0.0a0}/.gitignore +0 -0
- {modern_di_litestar-0.9.0 → modern_di_litestar-1.0.0a0}/README.md +0 -0
- {modern_di_litestar-0.9.0 → modern_di_litestar-1.0.0a0}/modern_di_litestar/__init__.py +0 -0
- {modern_di_litestar-0.9.0 → modern_di_litestar-1.0.0a0}/modern_di_litestar/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: modern-di-litestar
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0a0
|
|
4
4
|
Summary: Modern-DI integration for LiteStar
|
|
5
5
|
Project-URL: repository, https://github.com/modern-python/modern-di
|
|
6
6
|
Project-URL: docs, https://modern-di.readthedocs.io
|
|
@@ -15,7 +15,7 @@ Classifier: Topic :: Software Development :: Libraries
|
|
|
15
15
|
Classifier: Typing :: Typed
|
|
16
16
|
Requires-Python: <4,>=3.10
|
|
17
17
|
Requires-Dist: litestar
|
|
18
|
-
Requires-Dist: modern-di
|
|
18
|
+
Requires-Dist: modern-di>=1
|
|
19
19
|
Description-Content-Type: text/markdown
|
|
20
20
|
|
|
21
21
|
"Modern-DI-LiteStar"
|
|
@@ -26,11 +26,10 @@ async def _lifespan_manager(app_: litestar.Litestar) -> typing.AsyncIterator[Non
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
class ModernDIPlugin(InitPlugin):
|
|
29
|
-
__slots__ = ("container",
|
|
29
|
+
__slots__ = ("container",)
|
|
30
30
|
|
|
31
|
-
def __init__(self,
|
|
32
|
-
self.
|
|
33
|
-
self.container = container or AsyncContainer(scope=self.scope)
|
|
31
|
+
def __init__(self, container: AsyncContainer) -> None:
|
|
32
|
+
self.container = container
|
|
34
33
|
|
|
35
34
|
def on_app_init(self, app_config: AppConfig) -> AppConfig:
|
|
36
35
|
app_config.state.di_container = self.container
|
|
@@ -57,14 +56,16 @@ async def build_di_container(
|
|
|
57
56
|
|
|
58
57
|
@dataclasses.dataclass(slots=True, frozen=True)
|
|
59
58
|
class _Dependency(typing.Generic[T_co]):
|
|
60
|
-
dependency: providers.AbstractProvider[T_co]
|
|
59
|
+
dependency: providers.AbstractProvider[T_co] | type[T_co]
|
|
61
60
|
|
|
62
61
|
async def __call__(
|
|
63
62
|
self, di_container: typing.Annotated[AsyncContainer | None, Dependency(skip_validation=True)] = None
|
|
64
63
|
) -> T_co | None:
|
|
65
64
|
assert di_container
|
|
66
|
-
|
|
65
|
+
if isinstance(self.dependency, providers.AbstractProvider):
|
|
66
|
+
return await di_container.resolve_provider(self.dependency)
|
|
67
|
+
return await di_container.resolve(dependency_type=self.dependency)
|
|
67
68
|
|
|
68
69
|
|
|
69
|
-
def FromDI(dependency: providers.AbstractProvider[T_co]) -> Provide: # noqa: N802
|
|
70
|
+
def FromDI(dependency: providers.AbstractProvider[T_co] | type[T_co]) -> Provide: # noqa: N802
|
|
70
71
|
return Provide(dependency=_Dependency(dependency), use_cache=False)
|
|
@@ -14,8 +14,8 @@ classifiers = [
|
|
|
14
14
|
"Typing :: Typed",
|
|
15
15
|
"Topic :: Software Development :: Libraries",
|
|
16
16
|
]
|
|
17
|
-
dependencies = ["litestar", "modern-di"]
|
|
18
|
-
version = "0.
|
|
17
|
+
dependencies = ["litestar", "modern-di>=1"]
|
|
18
|
+
version = "1.0.0a0"
|
|
19
19
|
|
|
20
20
|
[project.urls]
|
|
21
21
|
repository = "https://github.com/modern-python/modern-di"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|