From 2d27507338772f758c5ea9c1dcf9f2fb7f29cde3 Mon Sep 17 00:00:00 2001 From: firedotguy Date: Fri, 6 Feb 2026 22:15:16 +0300 Subject: [PATCH] fix: fix type warnings --- itd/client.py | 15 ++++++++------- itd/routes/posts.py | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/itd/client.py b/itd/client.py index 4e32033..6bb9d6c 100644 --- a/itd/client.py +++ b/itd/client.py @@ -395,7 +395,8 @@ class Client: post_id = UUID(post_id) attachment_ids = list(map(lambda id: UUID(id) if isinstance(id, str) else id, attachment_ids)) - res = add_comment(self.token, post_id, content, attachment_ids) + res = add_comment(self.token, post_id, content, cast(list[UUID], attachment_ids)) + if res.status_code == 422 and 'found' in res.json(): raise ValidationError(*list(res.json()['found'].items())[0]) if res.json().get('error', {}).get('code') == 'NOT_FOUND': @@ -428,7 +429,7 @@ class Client: author_id = UUID(author_id) attachment_ids = list(map(lambda id: UUID(id) if isinstance(id, str) else id, attachment_ids)) - res = add_reply_comment(self.token, comment_id, content, author_id, attachment_ids) + res = add_reply_comment(self.token, comment_id, content, author_id, cast(list[UUID], attachment_ids)) if res.status_code == 500 and 'Failed query' in res.text: raise NotFound('User') if res.status_code == 422 and 'found' in res.json(): @@ -648,13 +649,13 @@ class Client: @refresh_on_error - def create_post(self, content: str, wall_recipient_id: UUID | str | None = None, attach_ids: list[UUID | str] = []) -> NewPost: + def create_post(self, content: str, wall_recipient_id: UUID | str | None = None, attachment_ids: list[UUID | str] = []) -> NewPost: """Создать пост Args: content (str): Содержимое wall_recipient_id (UUID | str | None, optional): UUID пользователя (чтобы создать пост ему на стене). Defaults to None. - attach_ids (list[UUID | str], optional): UUID вложений. Defaults to []. + attachment_ids (list[UUID | str], optional): UUID вложений. Defaults to []. Raises: NotFound: Пользователь не найден @@ -665,9 +666,9 @@ class Client: """ if isinstance(wall_recipient_id, str): wall_recipient_id = UUID(wall_recipient_id) - attach_ids = list(map(lambda id: UUID(id) if isinstance(id, str) else id, attach_ids)) + attachment_ids = list(map(lambda id: UUID(id) if isinstance(id, str) else id, attachment_ids)) - res = create_post(self.token, content, wall_recipient_id, attach_ids) + res = create_post(self.token, content, wall_recipient_id, cast(list[UUID], attachment_ids)) if res.json().get('error', {}).get('code') == 'NOT_FOUND': raise NotFound('Wall recipient') if res.status_code == 422 and 'found' in res.json(): @@ -849,7 +850,7 @@ class Client: res.raise_for_status() @refresh_on_error - def get_liked_posts(self, username_or_id: str | UUID, limit: int = 20, cursor: int = 0): + def get_liked_posts(self, username_or_id: str | UUID, limit: int = 20, cursor: int = 0) -> tuple[list[Post], LikedPostsPagintaion]: res = get_liked_posts(self.token, username_or_id, limit, cursor) if res.json().get('error', {}).get('code') == 'NOT_FOUND': raise NotFound('User') diff --git a/itd/routes/posts.py b/itd/routes/posts.py index 34acae0..7476b88 100644 --- a/itd/routes/posts.py +++ b/itd/routes/posts.py @@ -3,12 +3,12 @@ from uuid import UUID from itd.request import fetch from itd.enums import PostsTab -def create_post(token: str, content: str, wall_recipient_id: UUID | None = None, attach_ids: list[UUID] = []): +def create_post(token: str, content: str, wall_recipient_id: UUID | None = None, attachment_ids: list[UUID] = []): data: dict = {'content': content} if wall_recipient_id: data['wallRecipientId'] = str(wall_recipient_id) - if attach_ids: - data['attachmentIds'] = list(map(str, attach_ids)) + if attachment_ids: + data['attachmentIds'] = list(map(str, attachment_ids)) return fetch(token, 'post', 'posts', data)