From b8f1d656ba4a70df851f9d05832c7e8d951832b0 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 17 Oct 2026 07:46:53 +0800 Subject: [PATCH] fix(types): type TMDB collection parts --- .../themoviedb/tmdbv3api/objs/collection.py | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/modules/themoviedb/tmdbv3api/objs/collection.py b/app/modules/themoviedb/tmdbv3api/objs/collection.py index 8699e7770..aac64d89f 100644 --- a/app/modules/themoviedb/tmdbv3api/objs/collection.py +++ b/app/modules/themoviedb/tmdbv3api/objs/collection.py @@ -1,3 +1,5 @@ +from typing import cast + from ..tmdb import TMDb, TMDbJson @@ -8,13 +10,16 @@ class Collection(TMDb): "translations": "/collection/%s/translations" } - def details(self, collection_id: int | str) -> TMDbJson: + def details(self, collection_id: int | str) -> list[dict[str, TMDbJson]]: """ Get collection details by id. :param collection_id: int :return: """ - return self._request_obj(self._urls["details"] % collection_id, key="parts") + return cast( + list[dict[str, TMDbJson]], + self._request_obj(self._urls["details"] % collection_id, key="parts"), + ) def images(self, collection_id: int | str) -> TMDbJson: """ @@ -33,13 +38,22 @@ class Collection(TMDb): return self._request_obj(self._urls["translations"] % collection_id, key="translations") # 异步版本方法 - async def async_details(self, collection_id: int | str) -> TMDbJson: + async def async_details( + self, + collection_id: int | str, + ) -> list[dict[str, TMDbJson]]: """ Get collection details by id.(异步版本) :param collection_id: int :return: """ - return await self._async_request_obj(self._urls["details"] % collection_id, key="parts") + return cast( + list[dict[str, TMDbJson]], + await self._async_request_obj( + self._urls["details"] % collection_id, + key="parts", + ), + ) async def async_images(self, collection_id: int | str) -> TMDbJson: """