fix: fix type warnings

This commit is contained in:
firedotguy
2026-02-06 22:15:16 +03:00
parent b2bd982c1b
commit 2d27507338
2 changed files with 11 additions and 10 deletions

View File

@@ -395,7 +395,8 @@ class Client:
post_id = UUID(post_id) post_id = UUID(post_id)
attachment_ids = list(map(lambda id: UUID(id) if isinstance(id, str) else id, attachment_ids)) 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(): if res.status_code == 422 and 'found' in res.json():
raise ValidationError(*list(res.json()['found'].items())[0]) raise ValidationError(*list(res.json()['found'].items())[0])
if res.json().get('error', {}).get('code') == 'NOT_FOUND': if res.json().get('error', {}).get('code') == 'NOT_FOUND':
@@ -428,7 +429,7 @@ class Client:
author_id = UUID(author_id) author_id = UUID(author_id)
attachment_ids = list(map(lambda id: UUID(id) if isinstance(id, str) else id, attachment_ids)) 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: if res.status_code == 500 and 'Failed query' in res.text:
raise NotFound('User') raise NotFound('User')
if res.status_code == 422 and 'found' in res.json(): if res.status_code == 422 and 'found' in res.json():
@@ -648,13 +649,13 @@ class Client:
@refresh_on_error @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: Args:
content (str): Содержимое content (str): Содержимое
wall_recipient_id (UUID | str | None, optional): UUID пользователя (чтобы создать пост ему на стене). Defaults to None. 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: Raises:
NotFound: Пользователь не найден NotFound: Пользователь не найден
@@ -665,9 +666,9 @@ class Client:
""" """
if isinstance(wall_recipient_id, str): if isinstance(wall_recipient_id, str):
wall_recipient_id = UUID(wall_recipient_id) 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': if res.json().get('error', {}).get('code') == 'NOT_FOUND':
raise NotFound('Wall recipient') raise NotFound('Wall recipient')
if res.status_code == 422 and 'found' in res.json(): if res.status_code == 422 and 'found' in res.json():
@@ -849,7 +850,7 @@ class Client:
res.raise_for_status() res.raise_for_status()
@refresh_on_error @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) res = get_liked_posts(self.token, username_or_id, limit, cursor)
if res.json().get('error', {}).get('code') == 'NOT_FOUND': if res.json().get('error', {}).get('code') == 'NOT_FOUND':
raise NotFound('User') raise NotFound('User')

View File

@@ -3,12 +3,12 @@ from uuid import UUID
from itd.request import fetch from itd.request import fetch
from itd.enums import PostsTab 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} data: dict = {'content': content}
if wall_recipient_id: if wall_recipient_id:
data['wallRecipientId'] = str(wall_recipient_id) data['wallRecipientId'] = str(wall_recipient_id)
if attach_ids: if attachment_ids:
data['attachmentIds'] = list(map(str, attach_ids)) data['attachmentIds'] = list(map(str, attachment_ids))
return fetch(token, 'post', 'posts', data) return fetch(token, 'post', 'posts', data)