modern-di-fastapi 0.7.0__tar.gz → 1.0.0__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_fastapi-0.7.0 → modern_di_fastapi-1.0.0}/PKG-INFO +3 -2
- {modern_di_fastapi-0.7.0 → modern_di_fastapi-1.0.0}/modern_di_fastapi/main.py +6 -6
- {modern_di_fastapi-0.7.0 → modern_di_fastapi-1.0.0}/pyproject.toml +3 -2
- {modern_di_fastapi-0.7.0 → modern_di_fastapi-1.0.0}/.gitignore +0 -0
- {modern_di_fastapi-0.7.0 → modern_di_fastapi-1.0.0}/README.md +0 -0
- {modern_di_fastapi-0.7.0 → modern_di_fastapi-1.0.0}/modern_di_fastapi/__init__.py +0 -0
- {modern_di_fastapi-0.7.0 → modern_di_fastapi-1.0.0}/modern_di_fastapi/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: modern-di-fastapi
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: Modern-DI integration for FastAPI
|
|
5
5
|
Project-URL: repository, https://github.com/modern-python/modern-di
|
|
6
6
|
Project-URL: docs, https://modern-di.readthedocs.io
|
|
@@ -11,11 +11,12 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
15
|
Classifier: Topic :: Software Development :: Libraries
|
|
15
16
|
Classifier: Typing :: Typed
|
|
16
17
|
Requires-Python: <4,>=3.10
|
|
17
18
|
Requires-Dist: fastapi>=0.100
|
|
18
|
-
Requires-Dist: modern-di
|
|
19
|
+
Requires-Dist: modern-di>=1.0.0alpha
|
|
19
20
|
Description-Content-Type: text/markdown
|
|
20
21
|
|
|
21
22
|
"Modern-DI-FastAPI"
|
|
@@ -21,9 +21,7 @@ async def _lifespan_manager(app_: fastapi.FastAPI) -> typing.AsyncIterator[None]
|
|
|
21
21
|
yield
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
def setup_di(app: fastapi.FastAPI,
|
|
25
|
-
if not container:
|
|
26
|
-
container = AsyncContainer(scope=scope)
|
|
24
|
+
def setup_di(app: fastapi.FastAPI, container: AsyncContainer) -> AsyncContainer:
|
|
27
25
|
app.state.di_container = container
|
|
28
26
|
old_lifespan_manager = app.router.lifespan_context
|
|
29
27
|
app.router.lifespan_context = _merge_lifespan_context(
|
|
@@ -49,13 +47,15 @@ async def build_di_container(connection: HTTPConnection) -> typing.AsyncIterator
|
|
|
49
47
|
|
|
50
48
|
@dataclasses.dataclass(slots=True, frozen=True)
|
|
51
49
|
class Dependency(typing.Generic[T_co]):
|
|
52
|
-
dependency: providers.AbstractProvider[T_co]
|
|
50
|
+
dependency: providers.AbstractProvider[T_co] | type[T_co]
|
|
53
51
|
|
|
54
52
|
async def __call__(
|
|
55
53
|
self, request_container: typing.Annotated[AsyncContainer, fastapi.Depends(build_di_container)]
|
|
56
54
|
) -> T_co:
|
|
57
|
-
|
|
55
|
+
if isinstance(self.dependency, providers.AbstractProvider):
|
|
56
|
+
return await request_container.resolve_provider(self.dependency)
|
|
57
|
+
return await request_container.resolve(dependency_type=self.dependency)
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
def FromDI(dependency: providers.AbstractProvider[T_co], *, use_cache: bool = True) -> T_co: # noqa: N802
|
|
60
|
+
def FromDI(dependency: providers.AbstractProvider[T_co] | type[T_co], *, use_cache: bool = True) -> T_co: # noqa: N802
|
|
61
61
|
return typing.cast(T_co, fastapi.Depends(dependency=Dependency(dependency), use_cache=use_cache))
|
|
@@ -11,11 +11,12 @@ classifiers = [
|
|
|
11
11
|
"Programming Language :: Python :: 3.11",
|
|
12
12
|
"Programming Language :: Python :: 3.12",
|
|
13
13
|
"Programming Language :: Python :: 3.13",
|
|
14
|
+
"Programming Language :: Python :: 3.14",
|
|
14
15
|
"Typing :: Typed",
|
|
15
16
|
"Topic :: Software Development :: Libraries",
|
|
16
17
|
]
|
|
17
|
-
dependencies = ["fastapi>=0.100", "modern-di"]
|
|
18
|
-
version = "0.
|
|
18
|
+
dependencies = ["fastapi>=0.100", "modern-di>=1.0.0alpha"]
|
|
19
|
+
version = "1.0.0"
|
|
19
20
|
|
|
20
21
|
[project.urls]
|
|
21
22
|
repository = "https://github.com/modern-python/modern-di"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|