From bf69165b3b94bf02d149e0776b57ddefd1559d71 Mon Sep 17 00:00:00 2001 From: yupix Date: Wed, 22 Nov 2023 09:27:17 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20IPartialRole=E3=81=AB=E5=90=AB?= =?UTF-8?q?=E3=81=BE=E3=82=8C=E3=82=8B=E5=B1=9E=E6=80=A7=E3=82=92IRole?= =?UTF-8?q?=E3=81=8B=E3=82=89=E5=89=8A=E9=99=A4=E3=81=97=E3=80=81=E7=B6=99?= =?UTF-8?q?=E6=89=BF=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mipac/types/roles.py | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/mipac/types/roles.py b/mipac/types/roles.py index 1d093fe..73a54c6 100644 --- a/mipac/types/roles.py +++ b/mipac/types/roles.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, NotRequired, TypedDict, TypeGuard +from typing import TYPE_CHECKING, Literal, NotRequired, TypedDict, TypeGuard if TYPE_CHECKING: from mipac.types.user import IMeDetailed, IUserDetailed @@ -43,35 +43,29 @@ class IRolePolicies(TypedDict): rate_limit_factor: IRolePolicieValue -class IRole(TypedDict): +class IPartialRole(TypedDict): id: str - created_at: str - updated_at: str name: str - description: str color: str | None icon_url: str | None - target: str + description: str # 空でもNoneではない + is_moderator: bool + is_administrator: bool + display_order: int + + +class IRole(IPartialRole): + created_at: str + updated_at: str + target: Literal["manual", "conditional"] cond_formula: dict is_public: bool - is_administrator: bool - is_moderator: bool + is_explorable: bool as_badge: bool can_edit_members_by_moderator: bool policies: IRolePolicies users_count: int -class IPartialRole(TypedDict): - id: str - name: str - color: str | None - icon_url: str | None - description: str # 空でもNoneではない - is_moderator: bool - is_administrator: bool - display_order: int - - def is_me_role(data: IMeRole | IRoleUser, me_id: str) -> TypeGuard[IMeRole]: return data["user"]["id"] == me_id and data["user"].get("avatar_id") is not None