fix(types): type TMDB collection parts

This commit is contained in:
jxxghp
2026-10-17 07:46:53 +08:00
parent 4027c9c5dc
commit b8f1d656ba

View File

@@ -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:
"""