From 42d128389edc43a9e84151155f810f1ab670b52e Mon Sep 17 00:00:00 2001 From: yupix Date: Fri, 16 Feb 2024 14:18:48 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BA=9B=E7=B4=B0=E3=81=AA=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mipac/actions/follow.py | 4 ++-- mipac/actions/note.py | 8 ++++---- mipac/errors/base.py | 6 +++--- mipac/models/roles.py | 32 ++++++++++++++++---------------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/mipac/actions/follow.py b/mipac/actions/follow.py index 91d4817..4c72551 100644 --- a/mipac/actions/follow.py +++ b/mipac/actions/follow.py @@ -54,10 +54,10 @@ class FollowActions(AbstractAction): user_id = user_id or self.__user_id data = {"userId": user_id} - res = await self.__session.request( + raw_user: IPartialUser = await self.__session.request( Route("POST", "/api/following/delete"), json=data, auth=True ) - return PartialUser(res, client=self.__client) + return PartialUser(raw_user=raw_user, client=self.__client) async def invalidate(self, user_id: str | None = None) -> PartialUser: """ diff --git a/mipac/actions/note.py b/mipac/actions/note.py index b25f32f..05cdb14 100644 --- a/mipac/actions/note.py +++ b/mipac/actions/note.py @@ -1287,13 +1287,13 @@ class NoteActions(ClientNoteActions): Note 取得したノートID """ - res = await self._session.request( + raw_note: INote = await self._session.request( Route("POST", "/api/notes/show"), json={"noteId": note_id}, auth=True, lower=True, ) - return Note(res, client=self._client) + return Note(raw_note=raw_note, client=self._client) @cache(group="get_note", override=True) async def fetch(self, note_id: str) -> Note: @@ -1313,13 +1313,13 @@ class NoteActions(ClientNoteActions): Note note """ - res = await self._session.request( + raw_note: INote = await self._session.request( Route("POST", "/api/notes/show"), json={"noteId": note_id}, auth=True, lower=True, ) - return Note(res, client=self._client) + return Note(raw_note=raw_note, client=self._client) async def gets( self, diff --git a/mipac/errors/base.py b/mipac/errors/base.py index 628add1..8054283 100644 --- a/mipac/errors/base.py +++ b/mipac/errors/base.py @@ -14,9 +14,9 @@ class APIError(Exception): if isinstance(data, dict): error = data.get("error", {}) if isinstance(error, dict): - self.code: str | None = error.get("code", "") - self.id: str | None = error.get("id") - self.message: str | None = error.get("message", "") + self.code = error.get("code", "") + self.id = error.get("id") + self.message = error.get("message", "") super().__init__(f"{self.message}\nRaw error: {self.raw} " if self.message else self.raw) def raise_error(self): diff --git a/mipac/models/roles.py b/mipac/models/roles.py index dec09e5..c0fd0e7 100644 --- a/mipac/models/roles.py +++ b/mipac/models/roles.py @@ -100,67 +100,67 @@ class RolePolicies: @property def antenna_limit(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("antenna_limit")) + return RolePolicyValue(self.__role_policies_data["antenna_limit"]) @property def gtl_available(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("gtl_available")) + return RolePolicyValue(self.__role_policies_data["gtl_available"]) @property def ltl_available(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("ltl_available")) + return RolePolicyValue(self.__role_policies_data["ltl_available"]) @property def can_public_note(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("can_public_note")) + return RolePolicyValue(self.__role_policies_data["can_public_note"]) @property def drive_capacity_mb(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("drive_capacity_mb")) + return RolePolicyValue(self.__role_policies_data["drive_capacity_mb"]) @property def can_invite(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("can_invite")) + return RolePolicyValue(self.__role_policies_data["can_invite"]) @property def can_manage_custom_emojis(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("can_manage_custom_emojis")) + return RolePolicyValue(self.__role_policies_data["can_manage_custom_emojis"]) @property def can_hide_ads(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("can_hide_ads")) + return RolePolicyValue(self.__role_policies_data["can_hide_ads"]) @property def pin_limit(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("pin_limit")) + return RolePolicyValue(self.__role_policies_data["pin_limit"]) @property def word_mute_limit(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("word_mute_limit")) + return RolePolicyValue(self.__role_policies_data["word_mute_limit"]) @property def webhook_limit(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("webhook_limit")) + return RolePolicyValue(self.__role_policies_data["webhook_limit"]) @property def clip_limit(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("clip_limit")) + return RolePolicyValue(self.__role_policies_data["clip_limit"]) @property def note_each_clips_limit(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("note_each_clips_limit")) + return RolePolicyValue(self.__role_policies_data["note_each_clips_limit"]) @property def user_list_limit(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("user_list_limit")) + return RolePolicyValue(self.__role_policies_data["user_list_limit"]) @property def user_each_user_lists_limit(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("user_each_user_lists_limit")) + return RolePolicyValue(self.__role_policies_data["user_each_user_lists_limit"]) @property def rate_limit_factor(self) -> RolePolicyValue: - return RolePolicyValue(self.__role_policies_data.get("rate_limit_factor")) + return RolePolicyValue(self.__role_policies_data["rate_limit_factor"]) class Role(PartialRole[IRole]):