From 1c95d45be436607d9fc7aae8c10fbd739ac5e63d Mon Sep 17 00:00:00 2001 From: Benexl Date: Sat, 26 Jul 2025 10:57:05 +0300 Subject: [PATCH] chore: ruff check --- fastanime/cli/commands/anilist/commands/download.py | 4 ++-- fastanime/cli/commands/anilist/commands/stats.py | 1 - fastanime/cli/commands/registry/commands/backup.py | 1 - fastanime/cli/commands/registry/commands/import_.py | 2 -- fastanime/cli/commands/update.py | 2 +- fastanime/cli/config/loader.py | 1 - fastanime/cli/interactive/menu/media/media_actions.py | 2 -- fastanime/cli/service/download/service.py | 2 +- fastanime/cli/service/registry/service.py | 5 +---- fastanime/core/downloader/torrents.py | 3 +-- fastanime/core/utils/fuzzy.py | 1 - fastanime/core/utils/normalizer.py | 1 - fastanime/libs/provider/scraping/utils.py | 2 +- tests/test_torrent_downloader.py | 3 +-- 14 files changed, 8 insertions(+), 22 deletions(-) diff --git a/fastanime/cli/commands/anilist/commands/download.py b/fastanime/cli/commands/anilist/commands/download.py index 30dcdd2..b3e6ae6 100644 --- a/fastanime/cli/commands/anilist/commands/download.py +++ b/fastanime/cli/commands/anilist/commands/download.py @@ -575,7 +575,7 @@ def _get_available_episodes(provider, anime, config, feedback): ) if not provider_anime_data: - feedback.warning(f"Failed to get anime details from provider") + feedback.warning("Failed to get anime details from provider") return [] # Check all available translation types @@ -967,7 +967,7 @@ def _show_final_statistics(download_service, feedback): stats = download_service.get_download_statistics() if stats: - console.print(f"\n[bold blue]Overall Download Statistics:[/bold blue]") + console.print("\n[bold blue]Overall Download Statistics:[/bold blue]") console.print(f"Total episodes tracked: {stats.get('total_episodes', 0)}") console.print(f"Successfully downloaded: {stats.get('downloaded', 0)}") console.print(f"Failed downloads: {stats.get('failed', 0)}") diff --git a/fastanime/cli/commands/anilist/commands/stats.py b/fastanime/cli/commands/anilist/commands/stats.py index 548c306..9a69eea 100644 --- a/fastanime/cli/commands/anilist/commands/stats.py +++ b/fastanime/cli/commands/anilist/commands/stats.py @@ -16,7 +16,6 @@ def stats(config: "AppConfig"): from rich.markdown import Markdown from rich.panel import Panel - from .....core.exceptions import FastAnimeError from .....libs.media_api.api import create_api_client from ....service.auth import AuthService from ....service.feedback import FeedbackService diff --git a/fastanime/cli/commands/registry/commands/backup.py b/fastanime/cli/commands/registry/commands/backup.py index 2c8bd3c..c88f786 100644 --- a/fastanime/cli/commands/registry/commands/backup.py +++ b/fastanime/cli/commands/registry/commands/backup.py @@ -2,7 +2,6 @@ Registry backup command - create full backups of the registry """ -import shutil import tarfile from pathlib import Path from datetime import datetime diff --git a/fastanime/cli/commands/registry/commands/import_.py b/fastanime/cli/commands/registry/commands/import_.py index 2a570b8..5d0ebee 100644 --- a/fastanime/cli/commands/registry/commands/import_.py +++ b/fastanime/cli/commands/registry/commands/import_.py @@ -346,8 +346,6 @@ def _import_data(registry_service, data: dict, merge: bool, dry_run: bool, feedb """Import data into the registry.""" from .....libs.media_api.types import ( MediaFormat, - MediaGenre, - MediaStatus, MediaType, ) diff --git a/fastanime/cli/commands/update.py b/fastanime/cli/commands/update.py index bc31b4b..4dadf43 100644 --- a/fastanime/cli/commands/update.py +++ b/fastanime/cli/commands/update.py @@ -124,7 +124,7 @@ def update( else: latest_version = release_json.get("tag_name", "unknown") print(f"[yellow]Update available: {latest_version}[/]") - print(f"[dim]Run 'fastanime update' to update[/]") + print("[dim]Run 'fastanime update' to update[/]") sys.exit(1) else: print("[cyan]Checking for updates and updating if necessary...[/]") diff --git a/fastanime/cli/config/loader.py b/fastanime/cli/config/loader.py index b484787..681b060 100644 --- a/fastanime/cli/config/loader.py +++ b/fastanime/cli/config/loader.py @@ -1,5 +1,4 @@ import configparser -import json from pathlib import Path from typing import Dict diff --git a/fastanime/cli/interactive/menu/media/media_actions.py b/fastanime/cli/interactive/menu/media/media_actions.py index a810c8b..5c3446d 100644 --- a/fastanime/cli/interactive/menu/media/media_actions.py +++ b/fastanime/cli/interactive/menu/media/media_actions.py @@ -343,7 +343,6 @@ def _view_info(ctx: Context, state: State) -> MenuAction: # Create next airing panel if available if media_item.next_airing: - from datetime import datetime airing_info_table = Table(show_header=False, box=box.SIMPLE) airing_info_table.add_column("Field", style="bold red") @@ -537,7 +536,6 @@ def _view_characters(ctx: Context, state: State) -> MenuAction: from rich.table import Table from rich.panel import Panel from rich.text import Text - from datetime import datetime console = Console() console.clear() diff --git a/fastanime/cli/service/download/service.py b/fastanime/cli/service/download/service.py index b208620..4bd9457 100644 --- a/fastanime/cli/service/download/service.py +++ b/fastanime/cli/service/download/service.py @@ -4,7 +4,7 @@ import logging from pathlib import Path from typing import Optional -from ....core.config.model import AppConfig, DownloadsConfig +from ....core.config.model import AppConfig from ....core.downloader.base import BaseDownloader from ....core.downloader.downloader import create_downloader from ....core.downloader.params import DownloadParams diff --git a/fastanime/cli/service/registry/service.py b/fastanime/cli/service/registry/service.py index 143e341..1bba450 100644 --- a/fastanime/cli/service/registry/service.py +++ b/fastanime/cli/service/registry/service.py @@ -2,7 +2,7 @@ import json import logging from datetime import datetime from pathlib import Path -from typing import TYPE_CHECKING, Dict, Generator, List, Optional, TypedDict +from typing import Dict, Generator, List, Optional, TypedDict from ....core.config.model import MediaRegistryConfig from ....core.exceptions import FastAnimeError @@ -12,7 +12,6 @@ from ....libs.media_api.types import ( MediaItem, MediaSearchResult, PageInfo, - UserListItem, UserMediaListStatus, ) from .models import ( @@ -586,7 +585,6 @@ class MediaRegistryService: ) -> list[tuple[int, str]]: """Get all episodes with a specific download status.""" try: - from .models import DownloadStatus episodes = [] for record in self.get_all_media_records(): @@ -602,7 +600,6 @@ class MediaRegistryService: def get_download_statistics(self) -> dict: """Get comprehensive download statistics.""" try: - from .models import DownloadStatus stats = { "total_episodes": 0, diff --git a/fastanime/core/downloader/torrents.py b/fastanime/core/downloader/torrents.py index e13c133..00ce006 100644 --- a/fastanime/core/downloader/torrents.py +++ b/fastanime/core/downloader/torrents.py @@ -4,8 +4,7 @@ import subprocess import tempfile import time from pathlib import Path -from typing import Optional, Dict, Any, Callable, Union -from urllib.parse import urlparse +from typing import Optional, Dict, Any, Callable from ..exceptions import FastAnimeError, DependencyNotFoundError diff --git a/fastanime/core/utils/fuzzy.py b/fastanime/core/utils/fuzzy.py index 3f3142b..4a601d9 100644 --- a/fastanime/core/utils/fuzzy.py +++ b/fastanime/core/utils/fuzzy.py @@ -30,7 +30,6 @@ Usage: """ import logging -from typing import Any, Optional, Union logger = logging.getLogger(__name__) diff --git a/fastanime/core/utils/normalizer.py b/fastanime/core/utils/normalizer.py index 086027a..c45ac43 100644 --- a/fastanime/core/utils/normalizer.py +++ b/fastanime/core/utils/normalizer.py @@ -44,7 +44,6 @@ Author: FastAnime Contributors import json import logging -from pathlib import Path from typing import Dict, Optional from ..constants import ASSETS_DIR diff --git a/fastanime/libs/provider/scraping/utils.py b/fastanime/libs/provider/scraping/utils.py index 9b3cce9..b241bcd 100644 --- a/fastanime/libs/provider/scraping/utils.py +++ b/fastanime/libs/provider/scraping/utils.py @@ -6,7 +6,7 @@ that was previously sourced from yt-dlp. """ import string -from typing import Union, Optional +from typing import Optional def encode_base_n(num: int, n: int, table: Optional[str] = None) -> str: diff --git a/tests/test_torrent_downloader.py b/tests/test_torrent_downloader.py index 0f0d8de..87c5793 100644 --- a/tests/test_torrent_downloader.py +++ b/tests/test_torrent_downloader.py @@ -5,9 +5,8 @@ Tests for the TorrentDownloader class. import tempfile import unittest from pathlib import Path -from unittest.mock import Mock, patch, MagicMock +from unittest.mock import Mock, patch -import pytest from fastanime.core.downloader.torrents import ( TorrentDownloader,