diff --git a/microbootstrap/bootstrappers/fastapi.py b/microbootstrap/bootstrappers/fastapi.py index b4df53b..74e044d 100644 --- a/microbootstrap/bootstrappers/fastapi.py +++ b/microbootstrap/bootstrappers/fastapi.py @@ -44,18 +44,10 @@ async def _wrapped_lifespan_manager(self, app: fastapi.FastAPI) -> typing.AsyncI async with self._lifespan_manager(app), self.application_config.lifespan(app): yield {} - def _choose_lifespan_manager( - self, - ) -> typing.Callable[[fastapi.FastAPI], typing.AsyncContextManager[dict[str, typing.Any]]]: - if self.application_config.lifespan: - return self._wrapped_lifespan_manager - - return self._lifespan_manager - def bootstrap_before(self) -> dict[str, typing.Any]: return { "debug": self.settings.service_debug, - "lifespan": self._choose_lifespan_manager(), + "lifespan": self._wrapped_lifespan_manager if self.application_config.lifespan else self._lifespan_manager, }