ruff: enable FAST lint

this mostly is replacing the response_model attribute with a return type
of that function since that's the more idiomatic way to do
This commit is contained in:
Marcel Hellwig
2026-01-04 14:11:09 +01:00
parent 97cb3b5c1e
commit eac58d2843
5 changed files with 43 additions and 67 deletions

View File

@@ -43,13 +43,12 @@ router = APIRouter()
@router.get(
"/search",
dependencies=[Depends(current_active_user)],
response_model=list[MetaDataProviderSearchResult],
)
def search_for_movie(
query: str,
movie_service: movie_service_dep,
metadata_provider: metadata_provider_dep,
):
) -> list[MetaDataProviderSearchResult]:
"""
Search for a movie on the configured metadata provider.
"""
@@ -61,12 +60,11 @@ def search_for_movie(
@router.get(
"/recommended",
dependencies=[Depends(current_active_user)],
response_model=list[MetaDataProviderSearchResult],
)
def get_popular_movies(
movie_service: movie_service_dep,
metadata_provider: metadata_provider_dep,
):
) -> list[MetaDataProviderSearchResult]:
"""
Get a list of recommended/popular movies from the metadata provider.
"""
@@ -82,11 +80,10 @@ def get_popular_movies(
"/importable",
status_code=status.HTTP_200_OK,
dependencies=[Depends(current_superuser)],
response_model=list[MediaImportSuggestion],
)
def get_all_importable_movies(
movie_service: movie_service_dep, metadata_provider: metadata_provider_dep
):
) -> list[MediaImportSuggestion]:
"""
Get a list of unknown movies that were detected in the movie directory and are importable.
"""
@@ -124,9 +121,8 @@ def import_detected_movie(
@router.get(
"",
dependencies=[Depends(current_active_user)],
response_model=list[PublicMovie],
)
def get_all_movies(movie_service: movie_service_dep):
def get_all_movies(movie_service: movie_service_dep) -> list[Movie]:
"""
Get all movies in the library.
"""
@@ -169,9 +165,10 @@ def add_a_movie(
@router.get(
"/torrents",
dependencies=[Depends(current_active_user)],
response_model=list[RichMovieTorrent],
)
def get_all_movies_with_torrents(movie_service: movie_service_dep):
def get_all_movies_with_torrents(
movie_service: movie_service_dep,
) -> list[RichMovieTorrent]:
"""
Get all movies that are associated with torrents.
"""
@@ -181,9 +178,8 @@ def get_all_movies_with_torrents(movie_service: movie_service_dep):
@router.get(
"/libraries",
dependencies=[Depends(current_active_user)],
response_model=list[LibraryItem],
)
def get_available_libraries():
def get_available_libraries() -> list[LibraryItem]:
"""
Get available Movie libraries from configuration.
"""
@@ -198,9 +194,8 @@ def get_available_libraries():
@router.get(
"/requests",
dependencies=[Depends(current_active_user)],
response_model=list[RichMovieRequest],
)
def get_all_movie_requests(movie_service: movie_service_dep):
def get_all_movie_requests(movie_service: movie_service_dep) -> list[RichMovieRequest]:
"""
Get all movie requests.
"""
@@ -210,13 +205,12 @@ def get_all_movie_requests(movie_service: movie_service_dep):
@router.post(
"/requests",
status_code=status.HTTP_201_CREATED,
response_model=MovieRequest,
)
def create_movie_request(
movie_service: movie_service_dep,
movie_request: CreateMovieRequest,
user: Annotated[UserRead, Depends(current_active_user)],
):
) -> MovieRequest:
"""
Create a new movie request.
"""
@@ -234,14 +228,13 @@ def create_movie_request(
@router.put(
"/requests/{movie_request_id}",
response_model=MovieRequest,
)
def update_movie_request(
movie_service: movie_service_dep,
movie_request_id: MovieRequestId,
update_movie_request: MovieRequestBase,
user: Annotated[UserRead, Depends(current_active_user)],
):
) -> MovieRequest:
"""
Update an existing movie request.
"""
@@ -298,9 +291,8 @@ def delete_movie_request(
@router.get(
"/{movie_id}",
dependencies=[Depends(current_active_user)],
response_model=PublicMovie,
)
def get_movie_by_id(movie_service: movie_service_dep, movie: movie_dep):
def get_movie_by_id(movie_service: movie_service_dep, movie: movie_dep) -> PublicMovie:
"""
Get details for a specific movie.
"""
@@ -331,7 +323,6 @@ def delete_a_movie(
@router.post(
"/{movie_id}/library",
dependencies=[Depends(current_superuser)],
response_model=None,
status_code=status.HTTP_204_NO_CONTENT,
)
def set_library(
@@ -349,9 +340,10 @@ def set_library(
@router.get(
"/{movie_id}/files",
dependencies=[Depends(current_active_user)],
response_model=list[PublicMovieFile],
)
def get_movie_files_by_movie_id(movie_service: movie_service_dep, movie: movie_dep):
def get_movie_files_by_movie_id(
movie_service: movie_service_dep, movie: movie_dep
) -> list[PublicMovieFile]:
"""
Get files associated with a specific movie.
"""
@@ -361,13 +353,12 @@ def get_movie_files_by_movie_id(movie_service: movie_service_dep, movie: movie_d
@router.get(
"/{movie_id}/torrents",
dependencies=[Depends(current_active_user)],
response_model=list[IndexerQueryResult],
)
def search_for_torrents_for_movie(
movie_service: movie_service_dep,
movie: movie_dep,
search_query_override: str | None = None,
):
) -> list[IndexerQueryResult]:
"""
Search for torrents for a specific movie.
"""
@@ -380,14 +371,13 @@ def search_for_torrents_for_movie(
"/{movie_id}/torrents",
status_code=status.HTTP_201_CREATED,
dependencies=[Depends(current_active_user)],
response_model=Torrent,
)
def download_torrent_for_movie(
movie_service: movie_service_dep,
movie: movie_dep,
public_indexer_result_id: IndexerQueryResultId,
override_file_path_suffix: str = "",
):
) -> Torrent:
"""
Trigger a download for a specific torrent for a movie.
"""

View File

@@ -15,9 +15,10 @@ router = APIRouter()
@router.get(
"",
dependencies=[Depends(current_active_user)],
response_model=list[Notification],
)
def get_all_notifications(notification_service: notification_service_dep):
def get_all_notifications(
notification_service: notification_service_dep,
) -> list[Notification]:
"""
Get all notifications.
"""
@@ -27,9 +28,10 @@ def get_all_notifications(notification_service: notification_service_dep):
@router.get(
"/unread",
dependencies=[Depends(current_active_user)],
response_model=list[Notification],
)
def get_unread_notifications(notification_service: notification_service_dep):
def get_unread_notifications(
notification_service: notification_service_dep,
) -> list[Notification]:
"""
Get all unread notifications.
"""
@@ -39,14 +41,13 @@ def get_unread_notifications(notification_service: notification_service_dep):
@router.get(
"/{notification_id}",
dependencies=[Depends(current_active_user)],
response_model=Notification,
responses={
status.HTTP_404_NOT_FOUND: {"description": "Notification not found"},
},
)
def get_notification(
notification_id: NotificationId, notification_service: notification_service_dep
):
) -> Notification:
"""
Get a specific notification by ID.
"""

View File

@@ -19,14 +19,13 @@ router = APIRouter()
"",
status_code=status.HTTP_200_OK,
dependencies=[Depends(current_active_user)],
response_model=list[Torrent],
)
def get_all_torrents(service: torrent_service_dep):
def get_all_torrents(service: torrent_service_dep) -> list[Torrent]:
return service.get_all_torrents()
@router.get("/{torrent_id}", status_code=status.HTTP_200_OK, response_model=Torrent)
def get_torrent(service: torrent_service_dep, torrent: torrent_dep):
@router.get("/{torrent_id}", status_code=status.HTTP_200_OK)
def get_torrent(service: torrent_service_dep, torrent: torrent_dep) -> Torrent:
return service.get_torrent_by_id(torrent_id=torrent.id)
@@ -66,14 +65,13 @@ def retry_torrent_download(
"/{torrent_id}/status",
status_code=status.HTTP_200_OK,
dependencies=[Depends(current_superuser)],
response_model=Torrent,
)
def update_torrent_status(
rep: torrent_repository_dep,
torrent: torrent_dep,
state: TorrentStatus | None = None,
imported: bool | None = None,
):
) -> Torrent:
if imported is not None:
torrent.imported = imported
if state is not None:

View File

@@ -47,11 +47,10 @@ router = APIRouter()
@router.get(
"/search",
dependencies=[Depends(current_active_user)],
response_model=list[MetaDataProviderSearchResult],
)
def search_metadata_providers_for_a_show(
tv_service: tv_service_dep, query: str, metadata_provider: metadata_provider_dep
):
) -> list[MetaDataProviderSearchResult]:
"""
Search for a show on the configured metadata provider.
"""
@@ -61,11 +60,10 @@ def search_metadata_providers_for_a_show(
@router.get(
"/recommended",
dependencies=[Depends(current_active_user)],
response_model=list[MetaDataProviderSearchResult],
)
def get_recommended_shows(
tv_service: tv_service_dep, metadata_provider: metadata_provider_dep
):
) -> list[MetaDataProviderSearchResult]:
"""
Get a list of recommended/popular shows from the metadata provider.
"""
@@ -81,11 +79,10 @@ def get_recommended_shows(
"/importable",
status_code=status.HTTP_200_OK,
dependencies=[Depends(current_superuser)],
response_model=list[MediaImportSuggestion],
)
def get_all_importable_shows(
tv_service: tv_service_dep, metadata_provider: metadata_provider_dep
):
) -> list[MediaImportSuggestion]:
"""
Get a list of unknown shows that were detected in the TV directory and are importable.
"""
@@ -117,9 +114,10 @@ def import_detected_show(tv_service: tv_service_dep, tv_show: show_dep, director
@router.get(
"/shows", dependencies=[Depends(current_active_user)], response_model=list[Show]
"/shows",
dependencies=[Depends(current_active_user)],
)
def get_all_shows(tv_service: tv_service_dep):
def get_all_shows(tv_service: tv_service_dep) -> list[Show]:
"""
Get all shows in the library.
"""
@@ -162,9 +160,8 @@ def add_a_show(
@router.get(
"/shows/torrents",
dependencies=[Depends(current_active_user)],
response_model=list[RichShowTorrent],
)
def get_shows_with_torrents(tv_service: tv_service_dep):
def get_shows_with_torrents(tv_service: tv_service_dep) -> list[RichShowTorrent]:
"""
Get all shows that are associated with torrents.
"""
@@ -175,9 +172,8 @@ def get_shows_with_torrents(tv_service: tv_service_dep):
@router.get(
"/shows/libraries",
dependencies=[Depends(current_active_user)],
response_model=list[LibraryItem],
)
def get_available_libraries():
def get_available_libraries() -> list[LibraryItem]:
"""
Get available TV libraries from configuration.
"""
@@ -192,7 +188,6 @@ def get_available_libraries():
@router.get(
"/shows/{show_id}",
dependencies=[Depends(current_active_user)],
response_model=PublicShow,
)
def get_a_show(show: show_dep, tv_service: tv_service_dep) -> PublicShow:
"""
@@ -225,7 +220,6 @@ def delete_a_show(
@router.post(
"/shows/{show_id}/metadata",
dependencies=[Depends(current_active_user)],
response_model=PublicShow,
)
def update_shows_metadata(
show: show_dep, tv_service: tv_service_dep, metadata_provider: metadata_provider_dep
@@ -240,7 +234,6 @@ def update_shows_metadata(
@router.post(
"/shows/{show_id}/continuousDownload",
dependencies=[Depends(current_superuser)],
response_model=PublicShow,
)
def set_continuous_download(
show: show_dep, tv_service: tv_service_dep, continuous_download: bool
@@ -257,7 +250,6 @@ def set_continuous_download(
@router.post(
"/shows/{show_id}/library",
dependencies=[Depends(current_superuser)],
response_model=None,
status_code=status.HTTP_204_NO_CONTENT,
)
def set_library(
@@ -275,9 +267,8 @@ def set_library(
@router.get(
"/shows/{show_id}/torrents",
dependencies=[Depends(current_active_user)],
response_model=RichShowTorrent,
)
def get_a_shows_torrents(show: show_dep, tv_service: tv_service_dep):
def get_a_shows_torrents(show: show_dep, tv_service: tv_service_dep) -> RichShowTorrent:
"""
Get torrents associated with a specific show.
"""
@@ -293,7 +284,6 @@ def get_a_shows_torrents(show: show_dep, tv_service: tv_service_dep):
"/seasons/requests",
status_code=status.HTTP_200_OK,
dependencies=[Depends(current_active_user)],
response_model=list[RichSeasonRequest],
)
def get_season_requests(tv_service: tv_service_dep) -> list[RichSeasonRequest]:
"""
@@ -397,7 +387,6 @@ def delete_season_request(
@router.get(
"/seasons/{season_id}",
dependencies=[Depends(current_active_user)],
response_model=Season,
)
def get_season(season: season_dep) -> Season:
"""
@@ -409,7 +398,6 @@ def get_season(season: season_dep) -> Season:
@router.get(
"/seasons/{season_id}/files",
dependencies=[Depends(current_active_user)],
response_model=list[PublicSeasonFile],
)
def get_season_files(
season: season_dep, tv_service: tv_service_dep
@@ -429,14 +417,13 @@ def get_season_files(
"/torrents",
status_code=status.HTTP_200_OK,
dependencies=[Depends(current_superuser)],
response_model=list[IndexerQueryResult],
)
def get_torrents_for_a_season(
tv_service: tv_service_dep,
show_id: ShowId,
season_number: int = 1,
search_query_override: str = None,
):
) -> list[IndexerQueryResult]:
"""
Search for torrents for a specific season of a show.
Default season_number is 1 because it often returns multi-season torrents.
@@ -451,7 +438,6 @@ def get_torrents_for_a_season(
@router.post(
"/torrents",
status_code=status.HTTP_200_OK,
response_model=Torrent,
dependencies=[Depends(current_superuser)],
)
def download_a_torrent(
@@ -459,7 +445,7 @@ def download_a_torrent(
public_indexer_result_id: IndexerQueryResultId,
show_id: ShowId,
override_file_path_suffix: str = "",
):
) -> Torrent:
"""
Trigger a download for a specific torrent.
"""
@@ -478,11 +464,10 @@ def download_a_torrent(
@router.get(
"/episodes/count",
status_code=status.HTTP_200_OK,
response_model=int,
description="Total number of episodes downloaded",
dependencies=[Depends(current_active_user)],
)
def get_total_count_of_downloaded_episodes(tv_service: tv_service_dep):
def get_total_count_of_downloaded_episodes(tv_service: tv_service_dep) -> int:
"""
Get the total count of downloaded episodes across all shows.
"""