diff --git a/app/modules/themoviedb/tmdbv3api/objs/change.py b/app/modules/themoviedb/tmdbv3api/objs/change.py index a4a4867e6..7f3ceea8a 100644 --- a/app/modules/themoviedb/tmdbv3api/objs/change.py +++ b/app/modules/themoviedb/tmdbv3api/objs/change.py @@ -1,14 +1,17 @@ -from ..tmdb import TMDb +from ..tmdb import TMDb, TMDbJson class Change(TMDb): + """提供电影、剧集和人物的变更列表查询。""" + _urls = { "movie": "/movie/changes", "tv": "/tv/changes", "person": "/person/changes" } - def _change_list(self, change_type, start_date="", end_date="", page=1): + def _change_list(self, change_type: str, start_date: str | None = "", end_date: str | None = "", page: int | None = 1) -> TMDbJson: + """拼装可选时间范围和页码,并原样返回变更列表。""" params = "page=%s" % page if start_date: params += "&start_date=%s" % start_date @@ -20,7 +23,8 @@ class Change(TMDb): key="results" ) - async def _async_change_list(self, change_type, start_date="", end_date="", page=1): + async def _async_change_list(self, change_type: str, start_date: str | None = "", end_date: str | None = "", page: int | None = 1) -> TMDbJson: + """拼装可选时间范围和页码,并原样返回变更列表。""" params = "page=%s" % page if start_date: params += "&start_date=%s" % start_date @@ -32,7 +36,7 @@ class Change(TMDb): key="results" ) - def movie_change_list(self, start_date="", end_date="", page=1): + def movie_change_list(self, start_date: str | None = "", end_date: str | None = "", page: int | None = 1) -> TMDbJson: """ Get the changes for a movie. By default only the last 24 hours are returned. You can query up to 14 days in a single query by using the start_date and end_date query parameters. @@ -43,7 +47,7 @@ class Change(TMDb): """ return self._change_list("movie", start_date=start_date, end_date=end_date, page=page) - async def async_movie_change_list(self, start_date="", end_date="", page=1): + async def async_movie_change_list(self, start_date: str | None = "", end_date: str | None = "", page: int | None = 1) -> TMDbJson: """ Get the changes for a movie. By default only the last 24 hours are returned.(异步版本) You can query up to 14 days in a single query by using the start_date and end_date query parameters. @@ -54,7 +58,7 @@ class Change(TMDb): """ return await self._async_change_list("movie", start_date=start_date, end_date=end_date, page=page) - def tv_change_list(self, start_date="", end_date="", page=1): + def tv_change_list(self, start_date: str | None = "", end_date: str | None = "", page: int | None = 1) -> TMDbJson: """ Get a list of all of the TV show ids that have been changed in the past 24 hours. You can query up to 14 days in a single query by using the start_date and end_date query parameters. @@ -65,7 +69,7 @@ class Change(TMDb): """ return self._change_list("tv", start_date=start_date, end_date=end_date, page=page) - async def async_tv_change_list(self, start_date="", end_date="", page=1): + async def async_tv_change_list(self, start_date: str | None = "", end_date: str | None = "", page: int | None = 1) -> TMDbJson: """ Get a list of all of the TV show ids that have been changed in the past 24 hours.(异步版本) You can query up to 14 days in a single query by using the start_date and end_date query parameters. @@ -76,7 +80,7 @@ class Change(TMDb): """ return await self._async_change_list("tv", start_date=start_date, end_date=end_date, page=page) - def person_change_list(self, start_date="", end_date="", page=1): + def person_change_list(self, start_date: str | None = "", end_date: str | None = "", page: int | None = 1) -> TMDbJson: """ Get a list of all of the person ids that have been changed in the past 24 hours. You can query up to 14 days in a single query by using the start_date and end_date query parameters. @@ -87,7 +91,7 @@ class Change(TMDb): """ return self._change_list("person", start_date=start_date, end_date=end_date, page=page) - async def async_person_change_list(self, start_date="", end_date="", page=1): + async def async_person_change_list(self, start_date: str | None = "", end_date: str | None = "", page: int | None = 1) -> TMDbJson: """ Get a list of all of the person ids that have been changed in the past 24 hours.(异步版本) You can query up to 14 days in a single query by using the start_date and end_date query parameters. diff --git a/mypy.ini b/mypy.ini index ecf594e42..b17a9d394 100644 --- a/mypy.ini +++ b/mypy.ini @@ -185,4 +185,5 @@ files = app/modules/themoviedb/tmdbv3api/objs/company.py, app/modules/themoviedb/tmdbv3api/objs/keyword.py, app/modules/themoviedb/tmdbv3api/objs/review.py, + app/modules/themoviedb/tmdbv3api/objs/change.py, scripts/architecture/async_blocking.py