Skip to content

Commit

Permalink
[melobot] Fix adapter could be None in di process
Browse files Browse the repository at this point in the history
  • Loading branch information
aicorein committed Jan 22, 2025
1 parent ef79640 commit 1c7d170
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/melobot/di.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,15 @@ async def fulfill(self, dep_scope: dict[Depends, Any]) -> Any:
return val


def _adapter_get(hint: Any) -> "Adapter | None":
def _adapter_get(hint: Any) -> "Adapter":
ctx = EventBuildInfoCtx()
try:
return ctx.get().adapter
except ctx.lookup_exc_cls:
return BotCtx().get().get_adapter(hint)
except ctx.lookup_exc_cls as e:
adapter = BotCtx().get().get_adapter(hint)
if adapter is None:
raise e
return adapter


def _custom_logger_get(hint: Any, data: CustomLogger) -> Any:
Expand Down

0 comments on commit 1c7d170

Please sign in to comment.