chore: Annoucementの型を明確に

pull/109/head
yupix 7 months ago
parent 8dfc32b1c5
commit 2931e3d869
No known key found for this signature in database
GPG Key ID: 2FF705F5C56D9C06

@ -3,7 +3,7 @@ from __future__ import annotations
from datetime import datetime
from typing import TYPE_CHECKING
from mipac.types.announcement import IAnnouncement, IAnnouncementDetailed
from mipac.types.announcement import AnnoucementDisplay, AnnoucementIcon, IAnnouncement, IAnnouncementDetailed
from mipac.utils.format import str_to_datetime
if TYPE_CHECKING:
@ -45,11 +45,11 @@ class Announcement:
return self.__announcement["image_url"]
@property
def icon(self) -> str | None:
def icon(self) -> AnnoucementIcon:
return self.__announcement["icon"]
@property
def display(self) -> str:
def display(self) -> AnnoucementDisplay:
return self.__announcement["display"]
@property
@ -113,11 +113,11 @@ class AnnouncementDetailed:
return self.__raw_announcement["image_url"]
@property
def icon(self) -> str | None:
def icon(self) -> AnnoucementIcon:
return self.__raw_announcement["icon"]
@property
def display(self) -> str:
def display(self) -> AnnoucementDisplay:
return self.__raw_announcement["display"]
@property

@ -1,6 +1,9 @@
from typing import NotRequired, TypedDict
from typing import Literal, NotRequired, TypedDict
AnnoucementIcon = Literal["info", "wanirng", "error", "success"]
AnnoucementDisplay = Literal["dialog", "normal", "banner"]
class IAnnouncement(TypedDict):
id: str
created_at: str
@ -8,14 +11,13 @@ class IAnnouncement(TypedDict):
text: str
title: str
image_url: str | None
icon: str
display: str
icon: AnnoucementIcon
display: AnnoucementDisplay
need_confirmation_to_read: bool
silence: bool
for_you: bool
is_read: NotRequired[bool]
class IAnnouncementDetailed(TypedDict):
"""管理者から見たアナウンス"""
@ -25,8 +27,8 @@ class IAnnouncementDetailed(TypedDict):
text: str
title: str
image_url: str | None
icon: str
display: str
icon: AnnoucementIcon
display: AnnoucementDisplay
need_confirmation_to_read: bool
silence: bool

Loading…
Cancel
Save