mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-09 23:30:13 +08:00
Run `ruff check app tests scripts --fix` with the configured rule set (E4/E7/E9/F/I): import sorting (I001), f-strings without placeholders (F541), lambda/variable/unused-import cleanups that ruff marks safe. Nine files whose only ruff debt sits next to pre-existing pylint import-resolution errors (lazy exports, sys.path script imports) or whose "unused" imports are reached through attribute access by tests are left untouched so the changed-file pylint gate and the benchmark tests stay green; their diagnostics remain in the baseline. app/startup/lifecycle/__init__.py and app/main.py import business modules after cache composition, import-path and stdio setup on purpose (the source comments document the contract), so declare E402 per-file-ignores for them instead of adding per-line noqa. Ruff ratchet watermark drops from 498 to 100; sync the baseline fixture and the optimization checklist figure. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
from typing import Optional
|
||
|
||
from app.application.service import ServiceBaseHelper
|
||
from app.schemas.system import DownloaderConf, ServiceInfo
|
||
from app.schemas.types import ModuleType, SystemConfigKey
|
||
|
||
|
||
class DownloaderHelper(ServiceBaseHelper[DownloaderConf]):
|
||
"""
|
||
下载器帮助类
|
||
"""
|
||
|
||
def __init__(self):
|
||
"""绑定下载器配置和下载器模块类型。"""
|
||
super().__init__(
|
||
config_key=SystemConfigKey.Downloaders,
|
||
conf_type=DownloaderConf,
|
||
module_type=ModuleType.Downloader
|
||
)
|
||
|
||
def is_downloader(
|
||
self,
|
||
service_type: Optional[str] = None,
|
||
service: Optional[ServiceInfo] = None,
|
||
name: Optional[str] = None,
|
||
) -> bool:
|
||
"""
|
||
通用的下载器类型判断方法
|
||
:param service_type: 下载器的类型名称(如 'qbittorrent', 'transmission', 'rtorrent')
|
||
:param service: 要判断的服务信息
|
||
:param name: 服务的名称
|
||
:return: 如果服务类型或实例为指定类型,返回 True;否则返回 False
|
||
"""
|
||
# 如果未提供 service 则通过 name 获取服务
|
||
service = service or self.get_service(name=name)
|
||
|
||
# 判断服务类型是否为指定类型
|
||
return bool(service and service.type == service_type)
|