chore: add mypy

This commit is contained in:
cătălin 2023-12-09 11:29:28 +01:00
commit cd5783b9f0
Signed by: catalin
GPG key ID: 0178DF42F43E5FD2
8 changed files with 128 additions and 82 deletions

View file

@ -1,7 +1,7 @@
from dataclasses import asdict, dataclass
from typing import Annotated, Literal
from litestar import Controller, Litestar, MediaType, Request, Response, get, put
from litestar import Controller, Litestar, MediaType, Response, get, put
from litestar.params import Parameter
from pydantic import UUID4
@ -35,26 +35,19 @@ class GroupController(Controller):
self.create_group_service = CreateGroupService(self.repo)
self.get_pair_service = GetPairService(self.repo)
@staticmethod
def _group2urls(participants: list[str], url: str) -> list[str]:
return [f"{url}/pair/{participant_name}" for participant_name in participants]
@get("/{group_uuid:uuid}")
async def get_participants(self, request: Request, group_uuid: UUID4) -> list[str]:
participants = await self.get_participants_service.run(group_uuid)
return self._group2urls(participants, request.url)
async def get_participants(self, group_uuid: UUID4) -> list[str]:
return await self.get_participants_service.run(group_uuid)
@put("/{group_uuid:uuid}")
async def create_group(
self,
request: Request,
group_uuid: UUID4,
data: CreateGroup,
) -> list[str]:
group = await self.create_group_service.run(
return await self.create_group_service.run(
Group(uuid=group_uuid, **asdict(data)),
)
return self._group2urls(group.participants, request.url)
@get("/{group_uuid:uuid}/pair/{participant_name:str}")
async def get_pair(