Fixed the ruff check command line errors

This commit is contained in:
Théo Bori
2025-07-30 18:33:52 +02:00
parent fd80149e74
commit 49ee1f9bbd
20 changed files with 32 additions and 84 deletions

View File

@@ -1 +1,3 @@
from .cmd import anilist
__all__ = ["anilist"]

View File

@@ -19,15 +19,11 @@ def stats(config: "AppConfig"):
from .....libs.media_api.api import create_api_client
from ....service.auth import AuthService
from ....service.feedback import FeedbackService
from ....service.registry import MediaRegistryService
console = Console()
feedback = FeedbackService(config)
auth = AuthService(config.general.media_api)
registry_service = MediaRegistryService(
config.general.media_api, config.media_registry
)
media_api_client = create_api_client(config.general.media_api, config)

View File

@@ -204,7 +204,6 @@ def download_anime(
anime_title: str,
episode: str,
):
from ...core.downloader import DownloadParams, create_downloader
from ...libs.provider.anime.params import EpisodeStreamsParams

View File

@@ -197,7 +197,6 @@ def _find_old_format_entries(registry_service: MediaRegistryService) -> list:
old_format = []
index = registry_service._load_index()
current_version = index.version
if index.version != REGISTRY_VERSION:
old_format.append(
{

View File

@@ -208,7 +208,9 @@ def _create_breakdown_table(
total = sum(data.values())
# Determine sorting method
sort_key = lambda item: item[0] if sort_by_key else item[1]
def sort_key(item):
return item[0] if sort_by_key else item[1]
sorted_data = sorted(data.items(), key=sort_key, reverse=reverse_sort)
# Apply limit if specified

View File

@@ -197,8 +197,6 @@ def _next_episode(ctx: Context, state: State) -> MenuAction:
feedback = ctx.feedback
config = ctx.config
media_item = state.media_api.media_item
current_episode_num = state.provider.episode
@@ -248,8 +246,6 @@ def _previous_episode(ctx: Context, state: State) -> MenuAction:
feedback = ctx.feedback
config = ctx.config
media_item = state.media_api.media_item
current_episode_num = state.provider.episode

View File

@@ -92,7 +92,7 @@ class WatchHistoryService:
start_time = None
try:
current_local_episode = str(int(current_local_episode) + 1)
except:
except Exception:
# incase its a float
pass
else:

View File

@@ -117,7 +117,6 @@ class PreviewCacheWorker(ManagedBackgroundWorker):
# Submit info generation task if needed
if config.general.preview in ("full", "text"):
info_path = self.info_cache_dir / hash_id
info_text = self._generate_info_text(media_item, config)
self.submit_function(self._save_info_text, info_text, hash_id)
@@ -434,7 +433,6 @@ class ReviewCacheWorker(ManagedBackgroundWorker):
for choice_str, review in choice_map.items():
hash_id = self._get_cache_hash(choice_str)
info_path = self.reviews_cache_dir / hash_id
preview_content = self._generate_review_preview_content(review, config)
self.submit_function(self._save_preview_content, preview_content, hash_id)
@@ -522,7 +520,6 @@ class CharacterCacheWorker(ManagedBackgroundWorker):
for choice_str, character in choice_map.items():
hash_id = self._get_cache_hash(choice_str)
info_path = self.characters_cache_dir / hash_id
preview_content = self._generate_character_preview_content(
character, config
@@ -645,7 +642,6 @@ class AiringScheduleCacheWorker(ManagedBackgroundWorker):
raise RuntimeError("AiringScheduleCacheWorker is not running")
hash_id = self._get_cache_hash(anime_title)
info_path = self.airing_schedule_cache_dir / hash_id
preview_content = self._generate_airing_schedule_preview_content(
anime_title, schedule_result, config

View File

@@ -7,15 +7,28 @@ GENERAL_PREFERRED_SPINNER = "smiley"
GENERAL_API_CLIENT = "anilist"
GENERAL_PREFERRED_TRACKER = "local"
GENERAL_PROVIDER = "allanime"
GENERAL_SELECTOR = lambda: "fzf" if detect.has_fzf() else "default"
def GENERAL_SELECTOR():
return "fzf" if detect.has_fzf() else "default"
GENERAL_AUTO_SELECT_ANIME_RESULT = True
GENERAL_ICONS = True
GENERAL_PREVIEW = lambda: "full" if detect.is_running_kitty_terminal() else "none"
def GENERAL_PREVIEW():
return "full" if detect.is_running_kitty_terminal() else "none"
GENERAL_SCALE_PREVIEW = True
GENERAL_SCALE_PREVIEW = False
GENERAL_IMAGE_RENDERER = (
lambda: "icat" if detect.is_running_kitty_terminal() else "chafa"
)
def GENERAL_IMAGE_RENDERER():
return "icat" if detect.is_running_kitty_terminal() else "chafa"
GENERAL_MANGA_VIEWER = "feh"
GENERAL_CHECK_FOR_UPDATES = True
GENERAL_CACHE_REQUESTS = True
@@ -38,9 +51,11 @@ STREAM_YTDLP_FORMAT = "best[height<=1080]/bestvideo[height<=1080]+bestaudio/best
STREAM_FORCE_FORWARD_TRACKING = True
STREAM_DEFAULT_MEDIA_LIST_TRACKING = "prompt"
STREAM_SUB_LANG = "eng"
STREAM_USE_IPC = (
lambda: True if PLATFORM != "win32" and not detect.is_running_in_termux() else False
)
def STREAM_USE_IPC():
return True if PLATFORM != "win32" and not detect.is_running_in_termux() else False
# WorkerConfig
WORKER_ENABLED = True

View File

@@ -1,5 +1,4 @@
# GeneralConfig
from .defaults import SESSIONS_DIR
GENERAL_PYGMENT_STYLE = "The pygment style to use"
GENERAL_PREFERRED_SPINNER = "The spinner to use"

View File

@@ -367,7 +367,7 @@ class DefaultDownloader(BaseDownloader):
try:
# Run ffmpeg - use silent flag to control ffmpeg output, not progress
process = subprocess.run(
subprocess.run(
args,
capture_output=params.silent, # Only suppress ffmpeg output if silent
text=True,

View File

@@ -28,7 +28,6 @@ class DownloadFactory:
elif downloader_name == "auto":
# Auto mode: prefer yt-dlp if available, fallback to default
try:
import yt_dlp
from .yt_dlp import YtDLPDownloader
return YtDLPDownloader(config)

View File

@@ -219,7 +219,7 @@ class YtDLPDownloader(BaseDownloader):
# Run the ffmpeg command
try:
process = subprocess.run(args)
subprocess.run(args)
final_output_path = video_path.parent / merged_filename
if final_output_path.exists():

View File

@@ -308,7 +308,6 @@ class FileLock:
with self.lock_file_path.open("r") as f:
lines = f.readlines()
if len(lines) >= 2:
locked_pid = int(lines[0].strip())
locked_timestamp = float(lines[1].strip())
current_time = time.time()
if current_time - locked_timestamp > self.stale_timeout:

View File

@@ -20,7 +20,6 @@ class FmHlsExtractor(BaseExtractor):
timeout=10,
)
response.raise_for_status()
streams = response.json()
embed_html = response.text.replace(" ", "").replace("\n", "")
vid = MP4_SERVER_JUICY_STREAM_REGEX.search(embed_html)
@@ -50,7 +49,6 @@ class OkExtractor(BaseExtractor):
timeout=10,
)
response.raise_for_status()
streams = response.json()
embed_html = response.text.replace(" ", "").replace("\n", "")
vid = MP4_SERVER_JUICY_STREAM_REGEX.search(embed_html)

View File

@@ -20,7 +20,6 @@ class SsHlsExtractor(BaseExtractor):
timeout=10,
)
response.raise_for_status()
embed_html = response.text.replace(" ", "").replace("\n", "")
streams = response.json()["links"]
return Server(

View File

@@ -19,7 +19,6 @@ class VidMp4Extractor(BaseExtractor):
f"https://{API_BASE_URL}{url.replace('clock', 'clock.json')}",
timeout=10,
)
embed_html = response.text.replace(" ", "").replace("\n", "")
response.raise_for_status()
streams = response.json()

View File

@@ -91,9 +91,6 @@ class AllAnimeEpisodeStreams(TypedDict):
links: [AllAnimeEpisodeStream]
Server = Literal["gogoanime", "dropbox", "wetransfer", "sharepoint"]
class AllAnimeEpisode(TypedDict):
episodeString: str
sourceUrls: list[AllAnimeSource]

View File

@@ -51,7 +51,7 @@ def debug_extractor(extractor_function):
f"[AllAnime@Server={args[3].get('sourceName', 'UNKNOWN')}]: {e}"
)
else:
return extractor_function(*args, **kwargs)
return extractor_function(*args)
return _provider_function_wrapper

View File

@@ -1,47 +0,0 @@
[tool.pytest.ini_options]
minversion = "6.0"
addopts = [
"-ra",
"--strict-markers",
"--strict-config",
"--cov=fastanime.cli.interactive",
"--cov-report=term-missing",
"--cov-report=html:htmlcov",
"--cov-report=xml",
"-v",
]
testpaths = [
"tests",
]
python_files = [
"test_*.py",
"*_test.py",
]
python_classes = [
"Test*",
]
python_functions = [
"test_*",
]
markers = [
"unit: Unit tests",
"integration: Integration tests",
"slow: Slow running tests",
"network: Tests requiring network access",
"auth: Tests requiring authentication",
]
filterwarnings = [
"ignore::DeprecationWarning",
"ignore::PendingDeprecationWarning",
]
# Test discovery patterns
collect_ignore = [
"setup.py",
]
# Pytest plugins
required_plugins = [
"pytest-cov",
"pytest-mock",
]