modern-di-fastapi 0.5.0__py3-none-any.whl → 0.6.0__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.
modern_di_fastapi/main.py CHANGED
@@ -22,14 +22,16 @@ async def _lifespan_manager(app_: fastapi.FastAPI) -> typing.AsyncIterator[None]
22
22
  yield
23
23
 
24
24
 
25
- def setup_di(app: fastapi.FastAPI, scope: enum.IntEnum = Scope.APP) -> Container:
26
- app.state.di_container = Container(scope=scope)
25
+ def setup_di(app: fastapi.FastAPI, scope: enum.IntEnum = Scope.APP, container: Container | None = None) -> Container:
26
+ if not container:
27
+ container = Container(scope=scope)
28
+ app.state.di_container = container
27
29
  old_lifespan_manager = app.router.lifespan_context
28
30
  app.router.lifespan_context = _merge_lifespan_context(
29
31
  old_lifespan_manager,
30
32
  _lifespan_manager,
31
33
  )
32
- return app.state.di_container
34
+ return container
33
35
 
34
36
 
35
37
  async def build_di_container(connection: HTTPConnection) -> typing.AsyncIterator[Container]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modern-di-fastapi
3
- Version: 0.5.0
3
+ Version: 0.6.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
@@ -0,0 +1,6 @@
1
+ modern_di_fastapi/__init__.py,sha256=t4ox50Pc4k7bDNprfg3_ujqj4dwidTTuzV9WRNH-EOs,190
2
+ modern_di_fastapi/main.py,sha256=9P8ljSnIN86KeTkL7me7pm5iT_r8DHW3s6EIbqONEzo,2148
3
+ modern_di_fastapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ modern_di_fastapi-0.6.0.dist-info/METADATA,sha256=qBOKjLpu4jR-MQx0fbtPxthvcEAyrQgDXQqZZ-FCktE,926
5
+ modern_di_fastapi-0.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
+ modern_di_fastapi-0.6.0.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- modern_di_fastapi/__init__.py,sha256=t4ox50Pc4k7bDNprfg3_ujqj4dwidTTuzV9WRNH-EOs,190
2
- modern_di_fastapi/main.py,sha256=qmrZTCbZ3QGF1UEbkxKAoUauNGIwgvjda4_ELaohXbg,2073
3
- modern_di_fastapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- modern_di_fastapi-0.5.0.dist-info/METADATA,sha256=LSbWWDOSrYSaBFbxWmJo6kdAMAmlLRC5vD0iB24dNEY,926
5
- modern_di_fastapi-0.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
- modern_di_fastapi-0.5.0.dist-info/RECORD,,