Skip to content

Commit

Permalink
bump dishka version
Browse files Browse the repository at this point in the history
  • Loading branch information
ychebyshev committed Mar 26, 2024
1 parent 2ddb0f4 commit 6564719
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 39 deletions.
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ openpyxl = "^3.0.10"
lxml = "^4.9.2"
matplotlib = "^3.7.1"
greenlet = "<3.0.0"
dishka = "0.6.0"
dishka = "0.8.0"
asgi-monitor = "^0.3.0"

[tool.poetry.group.dev]
Expand Down
16 changes: 0 additions & 16 deletions shvatka/infrastructure/scheduler/context.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
from dataclasses import dataclass

from aiogram import Bot
from dishka import AsyncContainer
from dishka.integrations.base import wrap_injection

from shvatka.core.interfaces.clients.file_storage import FileStorage
from shvatka.core.interfaces.scheduler import Scheduler
from shvatka.infrastructure.db.dao.holder import HolderDao


class ScheduledContextHolder:
"""
Expand All @@ -18,15 +11,6 @@ class ScheduledContextHolder:
dishka: AsyncContainer


@dataclass
class ScheduledContext:
dao: HolderDao # need wrappers or protocols
bot: Bot # need wrappers or protocols
file_storage: FileStorage
scheduler: Scheduler
game_log_chat: int


def inject(func):
async def wrapper(*args, **kwargs):
async with ScheduledContextHolder.dishka() as request_dishka:
Expand Down
35 changes: 17 additions & 18 deletions shvatka/infrastructure/scheduler/wrappers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import typing
from typing import Annotated

from aiogram import Bot
from dishka.integrations.base import Depends
from dishka.integrations.base import FromDishka

from shvatka.core.interfaces.clients.file_storage import FileStorage
from shvatka.infrastructure.db.dao.holder import HolderDao
Expand All @@ -21,9 +20,9 @@
async def prepare_game_wrapper(
game_id: int,
author_id: int,
dao: Annotated[HolderDao, Depends()],
bot: Annotated[Bot, Depends()],
file_storage: Annotated[FileStorage, Depends()],
dao: FromDishka[HolderDao],
bot: FromDishka[Bot],
file_storage: FromDishka[FileStorage],
) -> None:
author = await dao.player.get_by_id(author_id)
game = await dao.game.get_by_id(game_id, author)
Expand All @@ -38,11 +37,11 @@ async def prepare_game_wrapper(
async def start_game_wrapper(
game_id: int,
author_id: int,
dao: Annotated[HolderDao, Depends()],
bot: Annotated[Bot, Depends()],
file_storage: Annotated[FileStorage, Depends()],
scheduler: Annotated[Scheduler, Depends()],
config: Annotated[BotConfig, Depends()],
dao: FromDishka[HolderDao],
bot: FromDishka[Bot],
file_storage: FromDishka[FileStorage],
scheduler: FromDishka[Scheduler],
config: FromDishka[BotConfig],
):
game = await dao.game.get_full(game_id)
assert author_id == game.author.id
Expand All @@ -60,10 +59,10 @@ async def send_hint_wrapper(
level_id: int,
team_id: int,
hint_number: int,
dao: Annotated[HolderDao, Depends()],
bot: Annotated[Bot, Depends()],
file_storage: Annotated[FileStorage, Depends()],
scheduler: Annotated[Scheduler, Depends()],
dao: FromDishka[HolderDao],
bot: FromDishka[Bot],
file_storage: FromDishka[FileStorage],
scheduler: FromDishka[Scheduler],
):
level = await dao.level.get_by_id(level_id)
team = await dao.team.get_by_id(team_id)
Expand All @@ -84,10 +83,10 @@ async def send_hint_for_testing_wrapper(
game_id: int,
player_id: int,
hint_number: int,
dao: Annotated[HolderDao, Depends()],
bot: Annotated[Bot, Depends()],
file_storage: Annotated[FileStorage, Depends()],
scheduler: Annotated[Scheduler, Depends()],
dao: FromDishka[HolderDao],
bot: FromDishka[Bot],
file_storage: FromDishka[FileStorage],
scheduler: FromDishka[Scheduler],
):
level = await dao.level.get_by_id(level_id)
game = await dao.game.get_by_id(game_id)
Expand Down

0 comments on commit 6564719

Please sign in to comment.